mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-22 19:39:24 +01:00
chore: SO MUCH PORTING!
This commit is contained in:
parent
cf608e9f16
commit
62b1859abb
45 changed files with 2572 additions and 2610 deletions
|
@ -10,8 +10,8 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.api.booklet.internal;
|
||||
|
||||
import net.minecraft.client.gui.IGuiEventListener;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
|
@ -27,7 +27,7 @@ public abstract class GuiBookletBase extends Screen {
|
|||
|
||||
public abstract void renderSplitScaledAsciiString(String text, int x, int y, int color, boolean shadow, float scale, int length);
|
||||
|
||||
public abstract List<Button> getButtonList();
|
||||
public abstract List<IGuiEventListener> getButtonList();
|
||||
|
||||
public abstract int getGuiLeft();
|
||||
|
||||
|
|
|
@ -17,7 +17,8 @@ public class ItemTagsGenerator extends ItemTagsProvider {
|
|||
|
||||
@Override
|
||||
protected void registerTags() {
|
||||
this.getOrCreateBuilder(ActuallyTags.Items.COFFEE_BEANS).add(ActuallyItems.itemCoffeeBean);
|
||||
this.getOrCreateBuilder(ActuallyTags.Items.COFFEE_BEANS)
|
||||
.add(ActuallyItems.itemCoffeeBean.get());
|
||||
// getOrCreateBuilder(ActuallyTags.Items.DRILLS).add(
|
||||
// ActuallyItems.DRILL_MAIN.get(),
|
||||
// ActuallyItems.DRILL_BLACK.get(), ActuallyItems.DRILL_BLACK.get(), ActuallyItems.DRILL_BLUE.get(), ActuallyItems.DRILL_BROWN.get(),
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.booklet.button;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
||||
|
@ -24,6 +25,7 @@ import net.minecraft.client.Minecraft;
|
|||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
@ -31,6 +33,7 @@ import net.minecraftforge.fml.client.gui.GuiUtils;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class BookmarkButton extends Button {
|
||||
|
@ -38,45 +41,45 @@ public class BookmarkButton extends Button {
|
|||
private final GuiBooklet booklet;
|
||||
public IBookletPage assignedPage;
|
||||
|
||||
public BookmarkButton(int id, int x, int y, GuiBooklet booklet) {
|
||||
super(id, x, y, 16, 16, "");
|
||||
public BookmarkButton(int x, int y, GuiBooklet booklet) {
|
||||
super(x, y, 16, 16, StringTextComponent.EMPTY, btn -> {
|
||||
BookmarkButton button = (BookmarkButton) btn;
|
||||
if (button.assignedPage != null) {
|
||||
if (Screen.hasShiftDown()) {
|
||||
button.assignedPage = null;
|
||||
} else if (!(button.booklet instanceof GuiPage) || ((GuiPage) button.booklet).pages[0] != button.assignedPage) {
|
||||
GuiPage gui = BookletUtils.createPageGui(button.booklet.previousScreen, button.booklet, button.assignedPage);
|
||||
Minecraft.getInstance().displayGuiScreen(gui);
|
||||
}
|
||||
} else {
|
||||
if (button.booklet instanceof GuiPage) {
|
||||
button.assignedPage = ((GuiPage) button.booklet).pages[0];
|
||||
}
|
||||
}
|
||||
});
|
||||
this.booklet = booklet;
|
||||
}
|
||||
|
||||
public void onPressed() {
|
||||
if (this.assignedPage != null) {
|
||||
if (Screen.hasShiftDown()) {
|
||||
this.assignedPage = null;
|
||||
} else if (!(this.booklet instanceof GuiPage) || ((GuiPage) this.booklet).pages[0] != this.assignedPage) {
|
||||
GuiPage gui = BookletUtils.createPageGui(this.booklet.previousScreen, this.booklet, this.assignedPage);
|
||||
Minecraft.getInstance().displayGuiScreen(gui);
|
||||
}
|
||||
} else {
|
||||
if (this.booklet instanceof GuiPage) {
|
||||
this.assignedPage = ((GuiPage) this.booklet).pages[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft minecraft, int x, int y, float f) {
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTicks) {
|
||||
if (this.visible) {
|
||||
minecraft.getTextureManager().bindTexture(GuiBooklet.RES_LOC_GADGETS);
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(GuiBooklet.RES_LOC_GADGETS);
|
||||
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.isHovered = x >= this.x && y >= this.y && x < this.x + this.width && y < this.y + this.height;
|
||||
int k = this.getHoverState(this.hovered);
|
||||
if (k == 0) {
|
||||
k = 1;
|
||||
}
|
||||
this.isHovered = mouseX >= this.x && mouseY >= this.y && this.x < this.x + this.width && this.y < this.y + this.height;
|
||||
int offset = this.isHovered
|
||||
? 1
|
||||
: 0;
|
||||
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
|
||||
GlStateManager.blendFuncSeparate(770, 771, 1, 0);
|
||||
GlStateManager.blendFunc(770, 771);
|
||||
int renderHeight = 25;
|
||||
this.blit(matrices, this.x, this.y, 224 + (this.assignedPage == null
|
||||
? 0
|
||||
: 16), 14 - renderHeight + k * renderHeight, this.width, renderHeight);
|
||||
this.mouseDragged(minecraft, x, y);
|
||||
: 16), 14 - renderHeight + offset * renderHeight, this.width, renderHeight);
|
||||
|
||||
// TODO: FIX THIS
|
||||
// this.mouseDragged(minecraft, mouseX, mouseY);
|
||||
|
||||
if (this.assignedPage != null) {
|
||||
ItemStack display = this.assignedPage.getChapter().getDisplayItemStack();
|
||||
|
@ -89,8 +92,8 @@ public class BookmarkButton extends Button {
|
|||
}
|
||||
}
|
||||
|
||||
public void drawHover(int mouseX, int mouseY) {
|
||||
if (this.isMouseOver()) {
|
||||
public void drawHover(MatrixStack stack, int mouseX, int mouseY) {
|
||||
if (this.isMouseOver(mouseX, mouseY)) {
|
||||
List<String> list = new ArrayList<>();
|
||||
|
||||
if (this.assignedPage != null) {
|
||||
|
@ -110,7 +113,7 @@ public class BookmarkButton extends Button {
|
|||
}
|
||||
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
GuiUtils.drawHoveringText(list, mouseX, mouseY, mc.displayWidth, mc.displayHeight, -1, mc.fontRenderer);
|
||||
GuiUtils.drawHoveringText(stack, list.stream().map(StringTextComponent::new).collect(Collectors.toList()), mouseX, mouseY, mc.currentScreen.width, mc.currentScreen.height, -1, mc.fontRenderer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,9 +20,8 @@ public class TrialsButton extends TexturedButton {
|
|||
|
||||
private final boolean isTrials;
|
||||
|
||||
public TrialsButton(GuiBooklet gui) {
|
||||
super(GuiBooklet.RES_LOC_GADGETS, gui.getGuiLeft() + gui.getSizeX(), gui.getGuiTop() + 10, 0, 204, 52, 16, btn -> {
|
||||
});
|
||||
public TrialsButton(GuiBooklet gui, IPressable action) {
|
||||
super(GuiBooklet.RES_LOC_GADGETS, gui.getGuiLeft() + gui.getSizeX(), gui.getGuiTop() + 10, 0, 204, 52, 16, action);
|
||||
this.isTrials = gui.areTrialsOpened();
|
||||
this.active = !this.isTrials;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.booklet.gui;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
|
||||
|
@ -23,20 +24,19 @@ import de.ellpeck.actuallyadditions.mod.inventory.gui.TexturedButton;
|
|||
import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import net.java.games.input.Keyboard;
|
||||
import net.java.games.input.Mouse;
|
||||
import net.minecraft.client.gui.IGuiEventListener;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public abstract class GuiBooklet extends GuiBookletBase {
|
||||
|
@ -63,6 +63,8 @@ public abstract class GuiBooklet extends GuiBookletBase {
|
|||
private float largeFontSize;
|
||||
|
||||
public GuiBooklet(Screen previousScreen, GuiBookletBase parentPage) {
|
||||
super(StringTextComponent.EMPTY);
|
||||
|
||||
this.previousScreen = previousScreen;
|
||||
this.parentPage = parentPage;
|
||||
|
||||
|
@ -96,37 +98,35 @@ public abstract class GuiBooklet extends GuiBookletBase {
|
|||
|
||||
if (this.hasPageLeftButton()) {
|
||||
List<String> hoverText = Arrays.asList(TextFormatting.GOLD + "Previous Page", TextFormatting.ITALIC + "Or scroll up");
|
||||
this.buttonLeft = new TexturedButton(RES_LOC_GADGETS, this.guiLeft - 12, this.guiTop + this.ySize - 8, 18, 54, 18, 10, hoverText, btn -> {
|
||||
});
|
||||
this.buttonLeft = new TexturedButton(RES_LOC_GADGETS, this.guiLeft - 12, this.guiTop + this.ySize - 8, 18, 54, 18, 10, hoverText, btn -> this.onPageLeftButtonPressed());
|
||||
this.addButton(this.buttonLeft);
|
||||
}
|
||||
|
||||
if (this.hasPageRightButton()) {
|
||||
List<String> hoverText = Arrays.asList(TextFormatting.GOLD + "Next Page", TextFormatting.ITALIC + "Or scroll down");
|
||||
this.buttonRight = new TexturedButton(RES_LOC_GADGETS, this.guiLeft + this.xSize - 6, this.guiTop + this.ySize - 8, 0, 54, 18, 10, hoverText, btn -> {
|
||||
});
|
||||
this.buttonRight = new TexturedButton(RES_LOC_GADGETS, this.guiLeft + this.xSize - 6, this.guiTop + this.ySize - 8, 0, 54, 18, 10, hoverText, btn -> this.onPageRightButtonPressed());
|
||||
this.addButton(this.buttonRight);
|
||||
}
|
||||
|
||||
if (this.hasBackButton()) {
|
||||
List<String> hoverText = Arrays.asList(TextFormatting.GOLD + "Go Back", TextFormatting.ITALIC + "Or right-click", TextFormatting.ITALIC.toString() + TextFormatting.GRAY + "Hold Shift for Main Page");
|
||||
this.buttonBack = new TexturedButton(RES_LOC_GADGETS, this.guiLeft - 15, this.guiTop - 3, 36, 54, 18, 10, hoverText, btn -> {
|
||||
});
|
||||
this.buttonBack = new TexturedButton(RES_LOC_GADGETS, this.guiLeft - 15, this.guiTop - 3, 36, 54, 18, 10, hoverText, btn -> this.onBackButtonPressed());
|
||||
this.addButton(this.buttonBack);
|
||||
}
|
||||
|
||||
if (this.hasSearchBar()) {
|
||||
this.searchField = new TextFieldWidget(-420, this.fontRenderer, this.guiLeft + this.xSize + 2, this.guiTop + this.ySize - 40 + 2, 64, 12);
|
||||
this.searchField = new TextFieldWidget(this.font, this.guiLeft + this.xSize + 2, this.guiTop + this.ySize - 40 + 2, 64, 12, StringTextComponent.EMPTY);
|
||||
this.searchField.setMaxStringLength(50);
|
||||
this.searchField.setEnableBackgroundDrawing(false);
|
||||
this.children.add(this.searchField);
|
||||
}
|
||||
|
||||
if (this.hasBookmarkButtons()) {
|
||||
PlayerSave data = PlayerData.getDataFromPlayer(this.mc.player);
|
||||
PlayerSave data = PlayerData.getDataFromPlayer(this.getMinecraft().player);
|
||||
|
||||
int xStart = this.guiLeft + this.xSize / 2 - 16 * this.bookmarkButtons.length / 2;
|
||||
for (int i = 0; i < this.bookmarkButtons.length; i++) {
|
||||
this.bookmarkButtons[i] = new BookmarkButton(1337 + i, xStart + i * 16, this.guiTop + this.ySize, this);
|
||||
this.bookmarkButtons[i] = new BookmarkButton(xStart + i * 16, this.guiTop + this.ySize, this);
|
||||
this.addButton(this.bookmarkButtons[i]);
|
||||
|
||||
if (data.bookmarks[i] != null) {
|
||||
|
@ -135,21 +135,21 @@ public abstract class GuiBooklet extends GuiBookletBase {
|
|||
}
|
||||
}
|
||||
|
||||
this.buttonTrials = new TrialsButton(this);
|
||||
this.buttonTrials = new TrialsButton(this, btn -> this.getMinecraft().displayGuiScreen(new GuiEntry(this.previousScreen, this, ActuallyAdditionsAPI.entryTrials, 0, "", false)));
|
||||
this.addButton(this.buttonTrials);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
super.onGuiClosed();
|
||||
public void onClose() {
|
||||
super.onClose();
|
||||
|
||||
//Don't cache the parent GUI, otherwise it opens again when you close the cached book!
|
||||
this.previousScreen = null;
|
||||
|
||||
if (this.mc.player == null) {
|
||||
if (this.getMinecraft().player == null) {
|
||||
return;
|
||||
}
|
||||
PlayerSave data = PlayerData.getDataFromPlayer(this.mc.player);
|
||||
PlayerSave data = PlayerData.getDataFromPlayer(this.getMinecraft().player);
|
||||
data.lastOpenBooklet = this;
|
||||
|
||||
boolean change = false;
|
||||
|
@ -166,85 +166,91 @@ public abstract class GuiBooklet extends GuiBookletBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
this.drawScreenPre(mouseX, mouseY, partialTicks);
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
this.drawScreenPost(mouseX, mouseY, partialTicks);
|
||||
public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
|
||||
this.drawScreenPre(matrixStack, mouseX, mouseY, partialTicks);
|
||||
super.render(matrixStack, mouseX, mouseY, partialTicks);
|
||||
this.drawScreenPost(matrixStack, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
public void drawScreenPre(int mouseX, int mouseY, float partialTicks) {
|
||||
GlStateManager.color(1F, 1F, 1F);
|
||||
public void drawScreenPre(MatrixStack matrices, int mouseX, int mouseY, float partialTicks) {
|
||||
GlStateManager.color4f(1F, 1F, 1F, 1F);
|
||||
this.getMinecraft().getTextureManager().bindTexture(RES_LOC_GUI);
|
||||
drawModalRectWithCustomSizedTexture(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize, 512, 512);
|
||||
blit(matrices, this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize, 512, 512);
|
||||
|
||||
if (this.hasSearchBar()) {
|
||||
this.getMinecraft().getTextureManager().bindTexture(RES_LOC_GADGETS);
|
||||
this.blit(matrices, this.guiLeft + this.xSize, this.guiTop + this.ySize - 40, 188, 0, 68, 14);
|
||||
|
||||
boolean unicodeBefore = this.fontRenderer.getUnicodeFlag();
|
||||
this.fontRenderer.setUnicodeFlag(true);
|
||||
// boolean unicodeBefore = this.font.getUnicodeFlag();
|
||||
// this.font.setUnicodeFlag(true);
|
||||
|
||||
if (!this.searchField.isFocused() && (this.searchField.getText() == null || this.searchField.getText().isEmpty())) {
|
||||
this.fontRenderer.drawString(TextFormatting.ITALIC + StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.searchField"), this.guiLeft + this.xSize + 2, this.guiTop + this.ySize - 40 + 2, 0xFFFFFF, false);
|
||||
this.font.drawString(matrices, TextFormatting.ITALIC + StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.searchField"), this.guiLeft + this.xSize + 2, this.guiTop + this.ySize - 40 + 2, 0xFFFFFF);
|
||||
}
|
||||
|
||||
this.searchField.drawTextBox();
|
||||
this.searchField.render(matrices, mouseX, mouseY, partialTicks);
|
||||
|
||||
this.fontRenderer.setUnicodeFlag(unicodeBefore);
|
||||
// this.font.setUnicodeFlag(unicodeBefore);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawScreenPost(int mouseX, int mouseY, float partialTicks) {
|
||||
for (GuiButton button : this.buttonList) {
|
||||
public void drawScreenPost(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
|
||||
for (IGuiEventListener button : this.children) {
|
||||
if (button instanceof BookmarkButton) {
|
||||
((BookmarkButton) button).drawHover(mouseX, mouseY);
|
||||
((BookmarkButton) button).drawHover(matrixStack, mouseX, mouseY);
|
||||
} else if (button instanceof TexturedButton) {
|
||||
((TexturedButton) button).drawHover(mouseX, mouseY);
|
||||
((TexturedButton) button).drawHover(matrixStack, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
|
||||
if (this.hasSearchBar()) {
|
||||
this.searchField.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
if (mouseButton == 1 && this.hasBackButton()) {
|
||||
this.onBackButtonPressed();
|
||||
}
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||
return super.mouseClicked(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
// TODO: Ensure replacement works
|
||||
@Override
|
||||
public void handleMouseInput() throws IOException {
|
||||
int wheel = Mouse.getEventDWheel();
|
||||
if (wheel != 0) {
|
||||
if (wheel < 0) {
|
||||
if (this.hasPageRightButton()) {
|
||||
this.onPageRightButtonPressed();
|
||||
}
|
||||
} else if (wheel > 0) {
|
||||
if (this.hasPageLeftButton()) {
|
||||
this.onPageLeftButtonPressed();
|
||||
}
|
||||
public boolean mouseScrolled(double mouseX, double mouseY, double delta) {
|
||||
if (delta < 0) {
|
||||
if (this.hasPageRightButton()) {
|
||||
this.onPageRightButtonPressed();
|
||||
}
|
||||
} else if (delta > 0) {
|
||||
if (this.hasPageLeftButton()) {
|
||||
this.onPageLeftButtonPressed();
|
||||
}
|
||||
}
|
||||
super.handleMouseInput();
|
||||
return super.mouseScrolled(mouseX, mouseY, delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen() {
|
||||
super.updateScreen();
|
||||
// @Override
|
||||
// public void handleMouseInput() throws IOException {
|
||||
// int wheel = Mouse.getEventDWheel();
|
||||
// if (wheel != 0) {
|
||||
// if (wheel < 0) {
|
||||
// if (this.hasPageRightButton()) {
|
||||
// this.onPageRightButtonPressed();
|
||||
// }
|
||||
// } else if (wheel > 0) {
|
||||
// if (this.hasPageLeftButton()) {
|
||||
// this.onPageLeftButtonPressed();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// super.handleMouseInput();
|
||||
// }
|
||||
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
if (this.hasSearchBar()) {
|
||||
this.searchField.updateCursorCounter();
|
||||
this.searchField.tick();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesGuiPauseGame() {
|
||||
public boolean isPauseScreen() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -273,7 +279,7 @@ public abstract class GuiBooklet extends GuiBookletBase {
|
|||
}
|
||||
|
||||
public void onBackButtonPressed() {
|
||||
this.mc.displayGuiScreen(new GuiMainPage(this.previousScreen));
|
||||
this.getMinecraft().displayGuiScreen(new GuiMainPage(this.previousScreen));
|
||||
}
|
||||
|
||||
public boolean hasSearchBar() {
|
||||
|
@ -299,64 +305,46 @@ public abstract class GuiBooklet extends GuiBookletBase {
|
|||
return this.largeFontSize;
|
||||
}
|
||||
|
||||
// TODO: Check if not being used
|
||||
public void onSearchBarChanged(String searchBarText) {
|
||||
GuiBookletBase parent = !(this instanceof GuiEntry)
|
||||
? this
|
||||
: this.parentPage;
|
||||
this.mc.displayGuiScreen(new GuiEntry(this.previousScreen, parent, ActuallyAdditionsAPI.entryAllAndSearch, 0, searchBarText, true));
|
||||
this.getMinecraft().displayGuiScreen(new GuiEntry(this.previousScreen, parent, ActuallyAdditionsAPI.entryAllAndSearch, 0, searchBarText, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) throws IOException {
|
||||
if (this.hasPageLeftButton() && button == this.buttonLeft) {
|
||||
this.onPageLeftButtonPressed();
|
||||
} else if (this.hasPageRightButton() && button == this.buttonRight) {
|
||||
this.onPageRightButtonPressed();
|
||||
} else if (this.hasBackButton() && button == this.buttonBack) {
|
||||
this.onBackButtonPressed();
|
||||
}
|
||||
if (button == this.buttonTrials) {
|
||||
this.mc.displayGuiScreen(new GuiEntry(this.previousScreen, this, ActuallyAdditionsAPI.entryTrials, 0, "", false));
|
||||
} else if (this.hasBookmarkButtons() && button instanceof BookmarkButton) {
|
||||
int index = ArrayUtils.indexOf(this.bookmarkButtons, button);
|
||||
if (index >= 0) {
|
||||
this.bookmarkButtons[index].onPressed();
|
||||
}
|
||||
} else {
|
||||
super.actionPerformed(button);
|
||||
}
|
||||
}
|
||||
// TODO: ensure typing still works
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char typedChar, int key) throws IOException {
|
||||
if (key == Keyboard.KEY_ESCAPE || key == this.mc.gameSettings.keyBindInventory.getKeyCode() && (!this.hasSearchBar() || !this.searchField.isFocused())) {
|
||||
this.mc.displayGuiScreen(this.previousScreen);
|
||||
} else if (this.hasSearchBar() & this.searchField.isFocused()) {
|
||||
String lastText = this.searchField.getText();
|
||||
|
||||
this.searchField.textboxKeyTyped(typedChar, key);
|
||||
|
||||
if (!lastText.equals(this.searchField.getText())) {
|
||||
this.onSearchBarChanged(this.searchField.getText());
|
||||
}
|
||||
} else {
|
||||
super.keyTyped(typedChar, key);
|
||||
}
|
||||
}
|
||||
// @Override
|
||||
// protected void keyTyped(char typedChar, int key) throws IOException {
|
||||
// if (key == Keyboard.KEY_ESCAPE || key == this.mc.gameSettings.keyBindInventory.getKeyCode() && (!this.hasSearchBar() || !this.searchField.isFocused())) {
|
||||
// this.mc.displayGuiScreen(this.previousScreen);
|
||||
// } else if (this.hasSearchBar() & this.searchField.isFocused()) {
|
||||
// String lastText = this.searchField.getText();
|
||||
//
|
||||
// this.searchField.textboxKeyTyped(typedChar, key);
|
||||
//
|
||||
// if (!lastText.equals(this.searchField.getText())) {
|
||||
// this.onSearchBarChanged(this.searchField.getText());
|
||||
// }
|
||||
// } else {
|
||||
// super.keyTyped(typedChar, key);
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void renderScaledAsciiString(String text, int x, int y, int color, boolean shadow, float scale) {
|
||||
StringUtil.renderScaledAsciiString(this.fontRenderer, text, x, y, color, shadow, scale);
|
||||
StringUtil.renderScaledAsciiString(this.font, text, x, y, color, shadow, scale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderSplitScaledAsciiString(String text, int x, int y, int color, boolean shadow, float scale, int length) {
|
||||
StringUtil.renderSplitScaledAsciiString(this.fontRenderer, text, x, y, color, shadow, scale, length);
|
||||
StringUtil.renderSplitScaledAsciiString(this.font, text, x, y, color, shadow, scale, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GuiButton> getButtonList() {
|
||||
return this.buttonList;
|
||||
public List<IGuiEventListener> getButtonList() {
|
||||
return this.children.stream().filter(e -> e instanceof Button).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,9 +15,9 @@ import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
|||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntListValues;
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
|
||||
|
|
|
@ -10,12 +10,9 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.crafting;
|
||||
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||
|
||||
// TODO: [port] MOVE TO DATA_GENERATOR
|
||||
@Deprecated
|
||||
public class RecipeBioMash extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe {
|
||||
public class RecipeBioMash { //extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe {
|
||||
//
|
||||
// public RecipeBioMash(ResourceLocation location) {
|
||||
// RecipeHelper.addRecipe(location.getPath(), this);
|
||||
|
|
|
@ -10,11 +10,9 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.crafting;
|
||||
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
|
||||
// TODO: [port] MOVE TO DATA_GENERATOR
|
||||
@Deprecated
|
||||
public class RecipeKeepDataShaped extends ShapedOreRecipe {
|
||||
public class RecipeKeepDataShaped { //extends ShapedOreRecipe {
|
||||
//
|
||||
// private final ItemStack nbtCopyStack;
|
||||
//
|
||||
|
|
|
@ -10,11 +10,9 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.crafting;
|
||||
|
||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
|
||||
// TODO: [port] MOVE TO DATA_GENERATOR
|
||||
@Deprecated
|
||||
public class RecipeKeepDataShapeless extends ShapelessOreRecipe {
|
||||
public class RecipeKeepDataShapeless {// extends ShapelessOreRecipe {
|
||||
//
|
||||
// private final ItemStack nbtCopyStack;
|
||||
//
|
||||
|
|
|
@ -10,12 +10,9 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.crafting;
|
||||
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||
|
||||
// TODO: [port] MOVE TO DATA_GENERATOR
|
||||
@Deprecated
|
||||
public class RecipePotionRingCharging extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe {
|
||||
public class RecipePotionRingCharging { //extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe {
|
||||
//
|
||||
// public RecipePotionRingCharging(ResourceLocation location) {
|
||||
// RecipeHelper.addRecipe(location.getPath(), this);
|
||||
|
|
|
@ -1,177 +1,177 @@
|
|||
/*
|
||||
* This file ("OreGen.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2017 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.gen;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.BlockMisc;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.BlockWildPlant;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheWildPlants;
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntListValues;
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
|
||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockHorizontal;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.pattern.BlockMatcher;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldType;
|
||||
import net.minecraft.world.biome.BiomeOcean;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraft.world.gen.IChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.WorldGenMinable;
|
||||
import net.minecraft.world.gen.structure.StructureBoundingBox;
|
||||
import net.minecraftforge.event.terraingen.DecorateBiomeEvent;
|
||||
import net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType;
|
||||
import net.minecraftforge.fml.common.IWorldGenerator;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
public class AAWorldGen implements IWorldGenerator {
|
||||
|
||||
public static final int QUARTZ_MIN = 0;
|
||||
public static final int QUARTZ_MAX = 45;
|
||||
|
||||
private final WorldGenLushCaves caveGen = new WorldGenLushCaves();
|
||||
|
||||
public AAWorldGen() {
|
||||
ActuallyAdditions.LOGGER.info("Registering World Generator...");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
|
||||
int dimension = world.provider.getDimension();
|
||||
if (dimension != -1 && dimension != 1) {
|
||||
if (world.getWorldType() != WorldType.FLAT && this.canGen(world.provider.getDimension())) {
|
||||
this.generateDefault(world, random, chunkX, chunkZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean canGen(int dimension) {
|
||||
boolean inList = ArrayUtils.contains(ConfigIntListValues.ORE_GEN_DIMENSION_BLACKLIST.getValue(), dimension);
|
||||
return (inList && ConfigBoolValues.ORE_GEN_DIM_WHITELIST.isEnabled()) || (!inList && !ConfigBoolValues.ORE_GEN_DIM_WHITELIST.isEnabled());
|
||||
}
|
||||
|
||||
private void generateDefault(World world, Random random, int x, int z) {
|
||||
if (ConfigBoolValues.GENERATE_QUARTZ.isEnabled()) {
|
||||
this.addOreSpawn(ActuallyBlocks.blockMisc.getDefaultState().withProperty(BlockMisc.TYPE, TheMiscBlocks.ORE_QUARTZ), Blocks.STONE, world, random, x * 16, z * 16, MathHelper.getInt(random, 5, 8), 10, QUARTZ_MIN, QUARTZ_MAX);
|
||||
}
|
||||
|
||||
if (ConfigBoolValues.GEN_LUSH_CAVES.isEnabled()) {
|
||||
|
||||
int randConst = 0x969ce69d;//so that it won't generate the same numbers as other mod that does the same thing
|
||||
Random chunkRand = new Random(randConst ^ world.getSeed() ^ (x * 29 + z * 31));
|
||||
|
||||
StructureBoundingBox box = new StructureBoundingBox(x * 16 + 8, 0, z * 16 + 8, x * 16 + 8 + 15, 255, z * 16 + 8 + 15);
|
||||
if (chunkRand.nextInt(ConfigIntValues.LUSH_CAVE_CHANCE.getValue()) <= 0) {
|
||||
BlockPos randPos = world.getTopSolidOrLiquidBlock(new BlockPos(x * 16 + MathHelper.getInt(random, 6, 10), 0, z * 16 + MathHelper.getInt(random, 6, 10)));
|
||||
BlockPos pos = randPos.down(MathHelper.getInt(chunkRand, 15, randPos.getY() - 15));
|
||||
|
||||
this.caveGen.generate(world, chunkRand, pos, box);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addOreSpawn(BlockState state, Block blockIn, World world, Random random, int blockXPos, int blockZPos, int maxVeinSize, int chancesToSpawn, int minY, int maxY) {
|
||||
for (int i = 0; i < chancesToSpawn; i++) {
|
||||
int posX = blockXPos + random.nextInt(16);
|
||||
int posY = minY + random.nextInt(maxY - minY);
|
||||
int posZ = blockZPos + random.nextInt(16);
|
||||
new WorldGenMinable(state, maxVeinSize, BlockMatcher.forBlock(blockIn)).generate(world, random, new BlockPos(posX, posY, posZ));
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onWorldDecoration(DecorateBiomeEvent.Decorate event) {
|
||||
if ((event.getResult() == Event.Result.ALLOW || event.getResult() == Event.Result.DEFAULT)) {
|
||||
if (event.getType() == EventType.FLOWERS) {
|
||||
if (!ArrayUtils.contains(ConfigIntListValues.PLANT_DIMENSION_BLACKLIST.getValue(), event.getWorld().provider.getDimension())) {
|
||||
this.generateRice(event);
|
||||
BlockState plantDefault = ActuallyBlocks.blockWildPlant.getDefaultState();
|
||||
this.genPlantNormally(plantDefault.withProperty(BlockWildPlant.TYPE, TheWildPlants.CANOLA), ConfigIntValues.CANOLA_AMOUNT.getValue(), ConfigBoolValues.DO_CANOLA_GEN.isEnabled(), Material.GRASS, event);
|
||||
this.genPlantNormally(plantDefault.withProperty(BlockWildPlant.TYPE, TheWildPlants.FLAX), ConfigIntValues.FLAX_AMOUNT.getValue(), ConfigBoolValues.DO_FLAX_GEN.isEnabled(), Material.GRASS, event);
|
||||
this.genPlantNormally(plantDefault.withProperty(BlockWildPlant.TYPE, TheWildPlants.COFFEE), ConfigIntValues.COFFEE_AMOUNT.getValue(), ConfigBoolValues.DO_COFFEE_GEN.isEnabled(), Material.GRASS, event);
|
||||
// this.genPlantNormally(InitBlocks.blockBlackLotus.getDefaultState(), ConfigIntValues.BLACK_LOTUS_AMOUNT.getValue(), ConfigBoolValues.DO_LOTUS_GEN.isEnabled(), Material.GRASS, event);
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getType() == EventType.LILYPAD) {
|
||||
//Generate Treasure Chests
|
||||
if (ConfigBoolValues.DO_TREASURE_CHEST_GEN.isEnabled()) {
|
||||
if (event.getRand().nextInt(40) == 0) {
|
||||
BlockPos randomPos = event.getChunkPos().getBlock(event.getRand().nextInt(16) + 8, 0, event.getRand().nextInt(16) + 8);
|
||||
randomPos = event.getWorld().getTopSolidOrLiquidBlock(randomPos);
|
||||
|
||||
if (event.getWorld().getBiome(randomPos) instanceof BiomeOcean) {
|
||||
if (randomPos.getY() >= 25 && randomPos.getY() <= 45) {
|
||||
if (event.getWorld().getBlockState(randomPos).getMaterial() == Material.WATER) {
|
||||
if (event.getWorld().getBlockState(randomPos.down()).getMaterial().isSolid()) {
|
||||
event.getWorld().setBlockState(randomPos, ActuallyBlocks.blockTreasureChest.getDefaultState().withProperty(BlockHorizontal.FACING, Direction.byHorizontalIndex(event.getRand().nextInt(4))), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void generateRice(DecorateBiomeEvent event) {
|
||||
if (ConfigBoolValues.DO_RICE_GEN.isEnabled()) {
|
||||
for (int i = 0; i < ConfigIntValues.RICE_AMOUNT.getValue(); i++) {
|
||||
if (event.getRand().nextInt(3) == 0) {
|
||||
BlockPos randomPos = event.getChunkPos().getBlock(event.getRand().nextInt(16) + 8, 0, event.getRand().nextInt(16) + 8);
|
||||
randomPos = event.getWorld().getTopSolidOrLiquidBlock(randomPos);
|
||||
if (event.getWorld().getBlockState(randomPos).getMaterial() == Material.WATER) {
|
||||
ArrayList<Material> blocksAroundBottom = WorldUtil.getMaterialsAround(event.getWorld(), randomPos);
|
||||
BlockPos posToGenAt = randomPos.up();
|
||||
ArrayList<Material> blocksAroundTop = WorldUtil.getMaterialsAround(event.getWorld(), posToGenAt);
|
||||
if (blocksAroundBottom.contains(Material.GRASS) || blocksAroundBottom.contains(Material.GROUND) || blocksAroundBottom.contains(Material.ROCK) || blocksAroundBottom.contains(Material.SAND)) {
|
||||
if (!blocksAroundTop.contains(Material.WATER) && event.getWorld().getBlockState(posToGenAt).getMaterial() == Material.AIR) {
|
||||
event.getWorld().setBlockState(posToGenAt, ActuallyBlocks.blockWildPlant.getDefaultState().withProperty(BlockWildPlant.TYPE, TheWildPlants.RICE), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void genPlantNormally(BlockState plant, int amount, boolean doIt, Material blockBelow, DecorateBiomeEvent event) {
|
||||
if (doIt) {
|
||||
for (int i = 0; i < amount; i++) {
|
||||
if (event.getRand().nextInt(100) == 0) {
|
||||
BlockPos randomPos = event.getChunkPos().getBlock(event.getRand().nextInt(16) + 8, 0, event.getRand().nextInt(16) + 8);
|
||||
randomPos = event.getWorld().getTopSolidOrLiquidBlock(randomPos);
|
||||
|
||||
if (event.getWorld().getBlockState(randomPos.down()).getMaterial() == blockBelow) {
|
||||
if (plant.getBlock().canPlaceBlockAt(event.getWorld(), randomPos) && event.getWorld().isAirBlock(randomPos)) {
|
||||
event.getWorld().setBlockState(randomPos, plant, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * This file ("OreGen.java") is part of the Actually Additions mod for Minecraft.
|
||||
// * It is created and owned by Ellpeck and distributed
|
||||
// * under the Actually Additions License to be found at
|
||||
// * http://ellpeck.de/actaddlicense
|
||||
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
// *
|
||||
// * © 2015-2017 Ellpeck
|
||||
// */
|
||||
//
|
||||
//package de.ellpeck.actuallyadditions.mod.gen;
|
||||
//
|
||||
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
//import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||
//import de.ellpeck.actuallyadditions.mod.blocks.BlockMisc;
|
||||
//import de.ellpeck.actuallyadditions.mod.blocks.BlockWildPlant;
|
||||
//import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks;
|
||||
//import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheWildPlants;
|
||||
//import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||
//import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntListValues;
|
||||
//import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
|
||||
//import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||
//import net.minecraft.block.Block;
|
||||
//import net.minecraft.block.BlockHorizontal;
|
||||
//import net.minecraft.block.BlockState;
|
||||
//import net.minecraft.block.material.Material;
|
||||
//import net.minecraft.block.state.pattern.BlockMatcher;
|
||||
//import net.minecraft.init.Blocks;
|
||||
//import net.minecraft.util.Direction;
|
||||
//import net.minecraft.util.math.BlockPos;
|
||||
//import net.minecraft.util.math.MathHelper;
|
||||
//import net.minecraft.world.World;
|
||||
//import net.minecraft.world.WorldType;
|
||||
//import net.minecraft.world.biome.BiomeOcean;
|
||||
//import net.minecraft.world.chunk.IChunkProvider;
|
||||
//import net.minecraft.world.gen.IChunkGenerator;
|
||||
//import net.minecraft.world.gen.feature.WorldGenMinable;
|
||||
//import net.minecraft.world.gen.structure.StructureBoundingBox;
|
||||
//import net.minecraftforge.event.terraingen.DecorateBiomeEvent;
|
||||
//import net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType;
|
||||
//import net.minecraftforge.fml.common.IWorldGenerator;
|
||||
//import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
//import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
//import org.apache.commons.lang3.ArrayUtils;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.Random;
|
||||
//
|
||||
//public class AAWorldGen implements IWorldGenerator {
|
||||
//
|
||||
// public static final int QUARTZ_MIN = 0;
|
||||
// public static final int QUARTZ_MAX = 45;
|
||||
//
|
||||
// private final WorldGenLushCaves caveGen = new WorldGenLushCaves();
|
||||
//
|
||||
// public AAWorldGen() {
|
||||
// ActuallyAdditions.LOGGER.info("Registering World Generator...");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
|
||||
// int dimension = world.provider.getDimension();
|
||||
// if (dimension != -1 && dimension != 1) {
|
||||
// if (world.getWorldType() != WorldType.FLAT && this.canGen(world.provider.getDimension())) {
|
||||
// this.generateDefault(world, random, chunkX, chunkZ);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private boolean canGen(int dimension) {
|
||||
// boolean inList = ArrayUtils.contains(ConfigIntListValues.ORE_GEN_DIMENSION_BLACKLIST.getValue(), dimension);
|
||||
// return (inList && ConfigBoolValues.ORE_GEN_DIM_WHITELIST.isEnabled()) || (!inList && !ConfigBoolValues.ORE_GEN_DIM_WHITELIST.isEnabled());
|
||||
// }
|
||||
//
|
||||
// private void generateDefault(World world, Random random, int x, int z) {
|
||||
// if (ConfigBoolValues.GENERATE_QUARTZ.isEnabled()) {
|
||||
// this.addOreSpawn(ActuallyBlocks.blockMisc.getDefaultState().withProperty(BlockMisc.TYPE, TheMiscBlocks.ORE_QUARTZ), Blocks.STONE, world, random, x * 16, z * 16, MathHelper.getInt(random, 5, 8), 10, QUARTZ_MIN, QUARTZ_MAX);
|
||||
// }
|
||||
//
|
||||
// if (ConfigBoolValues.GEN_LUSH_CAVES.isEnabled()) {
|
||||
//
|
||||
// int randConst = 0x969ce69d;//so that it won't generate the same numbers as other mod that does the same thing
|
||||
// Random chunkRand = new Random(randConst ^ world.getSeed() ^ (x * 29 + z * 31));
|
||||
//
|
||||
// StructureBoundingBox box = new StructureBoundingBox(x * 16 + 8, 0, z * 16 + 8, x * 16 + 8 + 15, 255, z * 16 + 8 + 15);
|
||||
// if (chunkRand.nextInt(ConfigIntValues.LUSH_CAVE_CHANCE.getValue()) <= 0) {
|
||||
// BlockPos randPos = world.getTopSolidOrLiquidBlock(new BlockPos(x * 16 + MathHelper.getInt(random, 6, 10), 0, z * 16 + MathHelper.getInt(random, 6, 10)));
|
||||
// BlockPos pos = randPos.down(MathHelper.getInt(chunkRand, 15, randPos.getY() - 15));
|
||||
//
|
||||
// this.caveGen.generate(world, chunkRand, pos, box);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void addOreSpawn(BlockState state, Block blockIn, World world, Random random, int blockXPos, int blockZPos, int maxVeinSize, int chancesToSpawn, int minY, int maxY) {
|
||||
// for (int i = 0; i < chancesToSpawn; i++) {
|
||||
// int posX = blockXPos + random.nextInt(16);
|
||||
// int posY = minY + random.nextInt(maxY - minY);
|
||||
// int posZ = blockZPos + random.nextInt(16);
|
||||
// new WorldGenMinable(state, maxVeinSize, BlockMatcher.forBlock(blockIn)).generate(world, random, new BlockPos(posX, posY, posZ));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @SubscribeEvent
|
||||
// public void onWorldDecoration(DecorateBiomeEvent.Decorate event) {
|
||||
// if ((event.getResult() == Event.Result.ALLOW || event.getResult() == Event.Result.DEFAULT)) {
|
||||
// if (event.getType() == EventType.FLOWERS) {
|
||||
// if (!ArrayUtils.contains(ConfigIntListValues.PLANT_DIMENSION_BLACKLIST.getValue(), event.getWorld().provider.getDimension())) {
|
||||
// this.generateRice(event);
|
||||
// BlockState plantDefault = ActuallyBlocks.blockWildPlant.getDefaultState();
|
||||
// this.genPlantNormally(plantDefault.withProperty(BlockWildPlant.TYPE, TheWildPlants.CANOLA), ConfigIntValues.CANOLA_AMOUNT.getValue(), ConfigBoolValues.DO_CANOLA_GEN.isEnabled(), Material.GRASS, event);
|
||||
// this.genPlantNormally(plantDefault.withProperty(BlockWildPlant.TYPE, TheWildPlants.FLAX), ConfigIntValues.FLAX_AMOUNT.getValue(), ConfigBoolValues.DO_FLAX_GEN.isEnabled(), Material.GRASS, event);
|
||||
// this.genPlantNormally(plantDefault.withProperty(BlockWildPlant.TYPE, TheWildPlants.COFFEE), ConfigIntValues.COFFEE_AMOUNT.getValue(), ConfigBoolValues.DO_COFFEE_GEN.isEnabled(), Material.GRASS, event);
|
||||
// // this.genPlantNormally(InitBlocks.blockBlackLotus.getDefaultState(), ConfigIntValues.BLACK_LOTUS_AMOUNT.getValue(), ConfigBoolValues.DO_LOTUS_GEN.isEnabled(), Material.GRASS, event);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (event.getType() == EventType.LILYPAD) {
|
||||
// //Generate Treasure Chests
|
||||
// if (ConfigBoolValues.DO_TREASURE_CHEST_GEN.isEnabled()) {
|
||||
// if (event.getRand().nextInt(40) == 0) {
|
||||
// BlockPos randomPos = event.getChunkPos().getBlock(event.getRand().nextInt(16) + 8, 0, event.getRand().nextInt(16) + 8);
|
||||
// randomPos = event.getWorld().getTopSolidOrLiquidBlock(randomPos);
|
||||
//
|
||||
// if (event.getWorld().getBiome(randomPos) instanceof BiomeOcean) {
|
||||
// if (randomPos.getY() >= 25 && randomPos.getY() <= 45) {
|
||||
// if (event.getWorld().getBlockState(randomPos).getMaterial() == Material.WATER) {
|
||||
// if (event.getWorld().getBlockState(randomPos.down()).getMaterial().isSolid()) {
|
||||
// event.getWorld().setBlockState(randomPos, ActuallyBlocks.blockTreasureChest.getDefaultState().withProperty(BlockHorizontal.FACING, Direction.byHorizontalIndex(event.getRand().nextInt(4))), 2);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void generateRice(DecorateBiomeEvent event) {
|
||||
// if (ConfigBoolValues.DO_RICE_GEN.isEnabled()) {
|
||||
// for (int i = 0; i < ConfigIntValues.RICE_AMOUNT.getValue(); i++) {
|
||||
// if (event.getRand().nextInt(3) == 0) {
|
||||
// BlockPos randomPos = event.getChunkPos().getBlock(event.getRand().nextInt(16) + 8, 0, event.getRand().nextInt(16) + 8);
|
||||
// randomPos = event.getWorld().getTopSolidOrLiquidBlock(randomPos);
|
||||
// if (event.getWorld().getBlockState(randomPos).getMaterial() == Material.WATER) {
|
||||
// ArrayList<Material> blocksAroundBottom = WorldUtil.getMaterialsAround(event.getWorld(), randomPos);
|
||||
// BlockPos posToGenAt = randomPos.up();
|
||||
// ArrayList<Material> blocksAroundTop = WorldUtil.getMaterialsAround(event.getWorld(), posToGenAt);
|
||||
// if (blocksAroundBottom.contains(Material.GRASS) || blocksAroundBottom.contains(Material.GROUND) || blocksAroundBottom.contains(Material.ROCK) || blocksAroundBottom.contains(Material.SAND)) {
|
||||
// if (!blocksAroundTop.contains(Material.WATER) && event.getWorld().getBlockState(posToGenAt).getMaterial() == Material.AIR) {
|
||||
// event.getWorld().setBlockState(posToGenAt, ActuallyBlocks.blockWildPlant.getDefaultState().withProperty(BlockWildPlant.TYPE, TheWildPlants.RICE), 2);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void genPlantNormally(BlockState plant, int amount, boolean doIt, Material blockBelow, DecorateBiomeEvent event) {
|
||||
// if (doIt) {
|
||||
// for (int i = 0; i < amount; i++) {
|
||||
// if (event.getRand().nextInt(100) == 0) {
|
||||
// BlockPos randomPos = event.getChunkPos().getBlock(event.getRand().nextInt(16) + 8, 0, event.getRand().nextInt(16) + 8);
|
||||
// randomPos = event.getWorld().getTopSolidOrLiquidBlock(randomPos);
|
||||
//
|
||||
// if (event.getWorld().getBlockState(randomPos.down()).getMaterial() == blockBelow) {
|
||||
// if (plant.getBlock().canPlaceBlockAt(event.getWorld(), randomPos) && event.getWorld().isAirBlock(randomPos)) {
|
||||
// event.getWorld().setBlockState(randomPos, plant, 2);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
|
|
@ -1,194 +1,194 @@
|
|||
/*
|
||||
* This file ("WorldGenLushCaves.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2017 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.gen;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||
import de.ellpeck.actuallyadditions.mod.misc.DungeonLoot;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChest;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDirectional;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.feature.WorldGenAbstractTree;
|
||||
import net.minecraft.world.gen.feature.WorldGenBigTree;
|
||||
import net.minecraft.world.gen.feature.WorldGenShrub;
|
||||
import net.minecraft.world.gen.feature.WorldGenTrees;
|
||||
import net.minecraft.world.gen.structure.StructureBoundingBox;
|
||||
import net.minecraft.world.storage.loot.ILootContainer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class WorldGenLushCaves {
|
||||
|
||||
public static final Block[] CRYSTAL_CLUSTERS = new Block[]{ActuallyBlocks.blockCrystalClusterRedstone, ActuallyBlocks.blockCrystalClusterLapis, ActuallyBlocks.blockCrystalClusterDiamond, ActuallyBlocks.blockCrystalClusterCoal, ActuallyBlocks.blockCrystalClusterEmerald, ActuallyBlocks.blockCrystalClusterIron};
|
||||
|
||||
public boolean generate(World world, Random rand, BlockPos position, StructureBoundingBox blockRegion) {
|
||||
this.generateCave(world, position, rand, blockRegion);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void generateCave(World world, BlockPos center, Random rand, StructureBoundingBox chunkRegion) {
|
||||
int spheres = rand.nextInt(5) + 3;
|
||||
StructureBoundingBox spheresBox = new StructureBoundingBox(chunkRegion);
|
||||
//the region for spheres is larger so that trees can generate in the smaller one
|
||||
spheresBox.minX -= 7;
|
||||
spheresBox.minZ -= 7;
|
||||
spheresBox.maxX += 7;
|
||||
spheresBox.maxZ += 7;
|
||||
for (int i = 0; i <= spheres; i++) {
|
||||
//center already is random value within population area
|
||||
this.makeSphereWithGrassFloor(world, center.add(rand.nextInt(11) - 5, rand.nextInt(7) - 3, rand.nextInt(11) - 5), rand.nextInt(3) + 5, spheresBox, rand);
|
||||
}
|
||||
|
||||
this.genTreesAndTallGrass(world, center, 11, spheres * 2, rand, chunkRegion);
|
||||
}
|
||||
|
||||
private void genTreesAndTallGrass(World world, BlockPos center, int radius, int amount, Random rand, StructureBoundingBox box) {
|
||||
List<BlockPos> possiblePoses = new ArrayList<>();
|
||||
for (double x = -radius; x < radius; x++) {
|
||||
for (double y = -radius; y < radius; y++) {
|
||||
for (double z = -radius; z < radius; z++) {
|
||||
BlockPos pos = center.add(x, y, z);
|
||||
if (box.isVecInside(pos)) {
|
||||
if (rand.nextDouble() >= 0.5D) {
|
||||
if (world.getBlockState(pos).getBlock() == Blocks.GRASS) {
|
||||
possiblePoses.add(pos);
|
||||
}
|
||||
} else {
|
||||
if (ConfigBoolValues.DO_CRYSTAL_CLUSTERS.isEnabled() && rand.nextInt(20) == 0) {
|
||||
Direction[] values = Direction.values();
|
||||
Direction side = values[rand.nextInt(values.length)];
|
||||
BlockPos posSide = pos.offset(side);
|
||||
|
||||
if (!this.checkIndestructable(world, posSide)) {
|
||||
BlockState state = world.getBlockState(pos);
|
||||
BlockState stateSide = world.getBlockState(posSide);
|
||||
|
||||
if (state.getBlock().isAir(state, world, pos) && stateSide.isSideSolid(world, posSide, side.getOpposite())) {
|
||||
Block block = CRYSTAL_CLUSTERS[rand.nextInt(CRYSTAL_CLUSTERS.length)];
|
||||
world.setBlockState(pos, block.getDefaultState().withProperty(BlockDirectional.FACING, side.getOpposite()), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!possiblePoses.isEmpty()) {
|
||||
boolean crateGenDone = false;
|
||||
|
||||
for (int i = 0; i <= amount; i++) {
|
||||
Collections.shuffle(possiblePoses);
|
||||
BlockPos pos = possiblePoses.get(0);
|
||||
if (rand.nextBoolean()) {
|
||||
boolean genCrate = false;
|
||||
|
||||
WorldGenAbstractTree trees;
|
||||
if (rand.nextBoolean()) {
|
||||
if (rand.nextBoolean()) {
|
||||
trees = new WorldGenBigTree(false);
|
||||
} else {
|
||||
trees = new WorldGenShrub(Blocks.LOG.getDefaultState(), Blocks.LEAVES.getDefaultState());
|
||||
genCrate = true;
|
||||
}
|
||||
} else {
|
||||
trees = new WorldGenTrees(false);
|
||||
}
|
||||
trees.generate(world, rand, pos.up());
|
||||
|
||||
if (ConfigBoolValues.DUNGEON_LOOT.isEnabled() && !crateGenDone && genCrate) {
|
||||
BlockPos cratePos = pos.add(MathHelper.getInt(rand, -2, 2), MathHelper.getInt(rand, 3, 8), MathHelper.getInt(rand, -2, 2));
|
||||
|
||||
BlockState state = world.getBlockState(cratePos);
|
||||
if (state != null && state.getBlock().isLeaves(state, world, cratePos)) {
|
||||
world.setBlockState(cratePos, ActuallyBlocks.blockGiantChest.getDefaultState(), 2);
|
||||
|
||||
TileEntity tile = world.getTileEntity(cratePos);
|
||||
if (tile instanceof TileEntityGiantChest) {
|
||||
((TileEntityGiantChest) tile).lootTable = DungeonLoot.LUSH_CAVES;
|
||||
}
|
||||
}
|
||||
|
||||
crateGenDone = true;
|
||||
}
|
||||
} else {
|
||||
Blocks.GRASS.grow(world, rand, pos, world.getBlockState(pos));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void makeSphereWithGrassFloor(World world, BlockPos center, int radius, StructureBoundingBox boundingBox, Random rand) {
|
||||
for (double x = -radius; x < radius; x++) {
|
||||
for (double y = -radius; y < radius; y++) {
|
||||
for (double z = -radius; z < radius; z++) {
|
||||
if (Math.sqrt(x * x + y * y + z * z) < radius) {
|
||||
BlockPos pos = center.add(x, y, z);
|
||||
//Note: order matters, checkIndestructable will generate chunks if order is reversed
|
||||
if (boundingBox.isVecInside(pos) && !this.checkIndestructable(world, pos)) {
|
||||
world.setBlockState(pos, Blocks.AIR.getDefaultState());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (double x = -radius; x < radius; x++) {
|
||||
for (double z = -radius; z < radius; z++) {
|
||||
for (double y = -radius; y <= -3; y++) {
|
||||
BlockPos pos = center.add(x, y, z);
|
||||
if (boundingBox.isVecInside(pos) && !this.checkIndestructable(world, pos)) {
|
||||
BlockState state = world.getBlockState(pos);
|
||||
BlockPos posUp = pos.up();
|
||||
|
||||
if (!this.checkIndestructable(world, posUp)) {
|
||||
BlockState stateUp = world.getBlockState(posUp);
|
||||
if (!state.getBlock().isAir(state, world, pos) && stateUp.getBlock().isAir(stateUp, world, posUp)) {
|
||||
world.setBlockState(pos, Blocks.GRASS.getDefaultState(), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkIndestructable(World world, BlockPos pos) {
|
||||
//If this isn't checked, the game crashes because it tries to destroy a chest that doesn't have any loot yet :v
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof ILootContainer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
BlockState state = world.getBlockState(pos);
|
||||
if (state != null) {
|
||||
Block block = state.getBlock();
|
||||
//check if it's tree or grass that is generated here
|
||||
if (block == Blocks.LOG || block == Blocks.LEAVES || block == Blocks.TALLGRASS) {
|
||||
return true;
|
||||
}
|
||||
if (block != null && (block.isAir(state, world, pos) || block.getHarvestLevel(state) >= 0F)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * This file ("WorldGenLushCaves.java") is part of the Actually Additions mod for Minecraft.
|
||||
// * It is created and owned by Ellpeck and distributed
|
||||
// * under the Actually Additions License to be found at
|
||||
// * http://ellpeck.de/actaddlicense
|
||||
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
// *
|
||||
// * © 2015-2017 Ellpeck
|
||||
// */
|
||||
//
|
||||
//package de.ellpeck.actuallyadditions.mod.gen;
|
||||
//
|
||||
//import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||
//import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||
//import de.ellpeck.actuallyadditions.mod.misc.DungeonLoot;
|
||||
//import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChest;
|
||||
//import net.minecraft.block.Block;
|
||||
//import net.minecraft.block.BlockDirectional;
|
||||
//import net.minecraft.init.Blocks;
|
||||
//import net.minecraft.tileentity.TileEntity;
|
||||
//import net.minecraft.util.Direction;
|
||||
//import net.minecraft.util.math.BlockPos;
|
||||
//import net.minecraft.util.math.MathHelper;
|
||||
//import net.minecraft.world.World;
|
||||
//import net.minecraft.world.gen.feature.WorldGenAbstractTree;
|
||||
//import net.minecraft.world.gen.feature.WorldGenBigTree;
|
||||
//import net.minecraft.world.gen.feature.WorldGenShrub;
|
||||
//import net.minecraft.world.gen.feature.WorldGenTrees;
|
||||
//import net.minecraft.world.gen.structure.StructureBoundingBox;
|
||||
//import net.minecraft.world.storage.loot.ILootContainer;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.Collections;
|
||||
//import java.util.List;
|
||||
//import java.util.Random;
|
||||
//
|
||||
//public class WorldGenLushCaves {
|
||||
//
|
||||
// public static final Block[] CRYSTAL_CLUSTERS = new Block[]{ActuallyBlocks.blockCrystalClusterRedstone, ActuallyBlocks.blockCrystalClusterLapis, ActuallyBlocks.blockCrystalClusterDiamond, ActuallyBlocks.blockCrystalClusterCoal, ActuallyBlocks.blockCrystalClusterEmerald, ActuallyBlocks.blockCrystalClusterIron};
|
||||
//
|
||||
// public boolean generate(World world, Random rand, BlockPos position, StructureBoundingBox blockRegion) {
|
||||
// this.generateCave(world, position, rand, blockRegion);
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// private void generateCave(World world, BlockPos center, Random rand, StructureBoundingBox chunkRegion) {
|
||||
// int spheres = rand.nextInt(5) + 3;
|
||||
// StructureBoundingBox spheresBox = new StructureBoundingBox(chunkRegion);
|
||||
// //the region for spheres is larger so that trees can generate in the smaller one
|
||||
// spheresBox.minX -= 7;
|
||||
// spheresBox.minZ -= 7;
|
||||
// spheresBox.maxX += 7;
|
||||
// spheresBox.maxZ += 7;
|
||||
// for (int i = 0; i <= spheres; i++) {
|
||||
// //center already is random value within population area
|
||||
// this.makeSphereWithGrassFloor(world, center.add(rand.nextInt(11) - 5, rand.nextInt(7) - 3, rand.nextInt(11) - 5), rand.nextInt(3) + 5, spheresBox, rand);
|
||||
// }
|
||||
//
|
||||
// this.genTreesAndTallGrass(world, center, 11, spheres * 2, rand, chunkRegion);
|
||||
// }
|
||||
//
|
||||
// private void genTreesAndTallGrass(World world, BlockPos center, int radius, int amount, Random rand, StructureBoundingBox box) {
|
||||
// List<BlockPos> possiblePoses = new ArrayList<>();
|
||||
// for (double x = -radius; x < radius; x++) {
|
||||
// for (double y = -radius; y < radius; y++) {
|
||||
// for (double z = -radius; z < radius; z++) {
|
||||
// BlockPos pos = center.add(x, y, z);
|
||||
// if (box.isVecInside(pos)) {
|
||||
// if (rand.nextDouble() >= 0.5D) {
|
||||
// if (world.getBlockState(pos).getBlock() == Blocks.GRASS) {
|
||||
// possiblePoses.add(pos);
|
||||
// }
|
||||
// } else {
|
||||
// if (ConfigBoolValues.DO_CRYSTAL_CLUSTERS.isEnabled() && rand.nextInt(20) == 0) {
|
||||
// Direction[] values = Direction.values();
|
||||
// Direction side = values[rand.nextInt(values.length)];
|
||||
// BlockPos posSide = pos.offset(side);
|
||||
//
|
||||
// if (!this.checkIndestructable(world, posSide)) {
|
||||
// BlockState state = world.getBlockState(pos);
|
||||
// BlockState stateSide = world.getBlockState(posSide);
|
||||
//
|
||||
// if (state.getBlock().isAir(state, world, pos) && stateSide.isSideSolid(world, posSide, side.getOpposite())) {
|
||||
// Block block = CRYSTAL_CLUSTERS[rand.nextInt(CRYSTAL_CLUSTERS.length)];
|
||||
// world.setBlockState(pos, block.getDefaultState().withProperty(BlockDirectional.FACING, side.getOpposite()), 2);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (!possiblePoses.isEmpty()) {
|
||||
// boolean crateGenDone = false;
|
||||
//
|
||||
// for (int i = 0; i <= amount; i++) {
|
||||
// Collections.shuffle(possiblePoses);
|
||||
// BlockPos pos = possiblePoses.get(0);
|
||||
// if (rand.nextBoolean()) {
|
||||
// boolean genCrate = false;
|
||||
//
|
||||
// WorldGenAbstractTree trees;
|
||||
// if (rand.nextBoolean()) {
|
||||
// if (rand.nextBoolean()) {
|
||||
// trees = new WorldGenBigTree(false);
|
||||
// } else {
|
||||
// trees = new WorldGenShrub(Blocks.LOG.getDefaultState(), Blocks.LEAVES.getDefaultState());
|
||||
// genCrate = true;
|
||||
// }
|
||||
// } else {
|
||||
// trees = new WorldGenTrees(false);
|
||||
// }
|
||||
// trees.generate(world, rand, pos.up());
|
||||
//
|
||||
// if (ConfigBoolValues.DUNGEON_LOOT.isEnabled() && !crateGenDone && genCrate) {
|
||||
// BlockPos cratePos = pos.add(MathHelper.getInt(rand, -2, 2), MathHelper.getInt(rand, 3, 8), MathHelper.getInt(rand, -2, 2));
|
||||
//
|
||||
// BlockState state = world.getBlockState(cratePos);
|
||||
// if (state != null && state.getBlock().isLeaves(state, world, cratePos)) {
|
||||
// world.setBlockState(cratePos, ActuallyBlocks.blockGiantChest.getDefaultState(), 2);
|
||||
//
|
||||
// TileEntity tile = world.getTileEntity(cratePos);
|
||||
// if (tile instanceof TileEntityGiantChest) {
|
||||
// ((TileEntityGiantChest) tile).lootTable = DungeonLoot.LUSH_CAVES;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// crateGenDone = true;
|
||||
// }
|
||||
// } else {
|
||||
// Blocks.GRASS.grow(world, rand, pos, world.getBlockState(pos));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void makeSphereWithGrassFloor(World world, BlockPos center, int radius, StructureBoundingBox boundingBox, Random rand) {
|
||||
// for (double x = -radius; x < radius; x++) {
|
||||
// for (double y = -radius; y < radius; y++) {
|
||||
// for (double z = -radius; z < radius; z++) {
|
||||
// if (Math.sqrt(x * x + y * y + z * z) < radius) {
|
||||
// BlockPos pos = center.add(x, y, z);
|
||||
// //Note: order matters, checkIndestructable will generate chunks if order is reversed
|
||||
// if (boundingBox.isVecInside(pos) && !this.checkIndestructable(world, pos)) {
|
||||
// world.setBlockState(pos, Blocks.AIR.getDefaultState());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// for (double x = -radius; x < radius; x++) {
|
||||
// for (double z = -radius; z < radius; z++) {
|
||||
// for (double y = -radius; y <= -3; y++) {
|
||||
// BlockPos pos = center.add(x, y, z);
|
||||
// if (boundingBox.isVecInside(pos) && !this.checkIndestructable(world, pos)) {
|
||||
// BlockState state = world.getBlockState(pos);
|
||||
// BlockPos posUp = pos.up();
|
||||
//
|
||||
// if (!this.checkIndestructable(world, posUp)) {
|
||||
// BlockState stateUp = world.getBlockState(posUp);
|
||||
// if (!state.getBlock().isAir(state, world, pos) && stateUp.getBlock().isAir(stateUp, world, posUp)) {
|
||||
// world.setBlockState(pos, Blocks.GRASS.getDefaultState(), 2);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private boolean checkIndestructable(World world, BlockPos pos) {
|
||||
// //If this isn't checked, the game crashes because it tries to destroy a chest that doesn't have any loot yet :v
|
||||
// TileEntity tile = world.getTileEntity(pos);
|
||||
// if (tile instanceof ILootContainer) {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// BlockState state = world.getBlockState(pos);
|
||||
// if (state != null) {
|
||||
// Block block = state.getBlock();
|
||||
// //check if it's tree or grass that is generated here
|
||||
// if (block == Blocks.LOG || block == Blocks.LEAVES || block == Blocks.TALLGRASS) {
|
||||
// return true;
|
||||
// }
|
||||
// if (block != null && (block.isAir(state, world, pos) || block.getHarvestLevel(state) >= 0F)) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
//}
|
||||
|
|
|
@ -1,53 +1,53 @@
|
|||
/*
|
||||
* This file ("BasicTradeList.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2017 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.gen.village;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.IMerchant;
|
||||
import net.minecraft.entity.passive.EntityVillager.ITradeList;
|
||||
import net.minecraft.entity.passive.EntityVillager.PriceInfo;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.village.MerchantRecipe;
|
||||
import net.minecraft.village.MerchantRecipeList;
|
||||
|
||||
public class BasicTradeList implements ITradeList {
|
||||
|
||||
private final ItemStack input;
|
||||
private final PriceInfo inputAmount;
|
||||
private final ItemStack output;
|
||||
private final PriceInfo outputAmount;
|
||||
|
||||
public BasicTradeList(ItemStack input, PriceInfo inputAmount, ItemStack output, PriceInfo outputAmount) {
|
||||
this.input = input;
|
||||
this.inputAmount = inputAmount;
|
||||
this.output = output;
|
||||
this.outputAmount = outputAmount;
|
||||
}
|
||||
|
||||
public BasicTradeList(PriceInfo emeraldInput, ItemStack output, PriceInfo outputAmount) {
|
||||
this(new ItemStack(Items.EMERALD), emeraldInput, output, outputAmount);
|
||||
}
|
||||
|
||||
public BasicTradeList(ItemStack input, PriceInfo inputAmount, PriceInfo emeraldOutput) {
|
||||
this(input, inputAmount, new ItemStack(Items.EMERALD), emeraldOutput);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMerchantRecipe(IMerchant merchant, MerchantRecipeList recipeList, Random random) {
|
||||
ItemStack in = this.input.copy();
|
||||
in.setCount(this.inputAmount.getPrice(random));
|
||||
ItemStack out = this.output.copy();
|
||||
out.setCount(this.outputAmount.getPrice(random));
|
||||
recipeList.add(new MerchantRecipe(in, out));
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * This file ("BasicTradeList.java") is part of the Actually Additions mod for Minecraft.
|
||||
// * It is created and owned by Ellpeck and distributed
|
||||
// * under the Actually Additions License to be found at
|
||||
// * http://ellpeck.de/actaddlicense
|
||||
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
// *
|
||||
// * © 2015-2017 Ellpeck
|
||||
// */
|
||||
//
|
||||
//package de.ellpeck.actuallyadditions.mod.gen.village;
|
||||
//
|
||||
//import java.util.Random;
|
||||
//
|
||||
//import net.minecraft.entity.IMerchant;
|
||||
//import net.minecraft.entity.passive.EntityVillager.ITradeList;
|
||||
//import net.minecraft.entity.passive.EntityVillager.PriceInfo;
|
||||
//import net.minecraft.init.Items;
|
||||
//import net.minecraft.item.ItemStack;
|
||||
//import net.minecraft.village.MerchantRecipe;
|
||||
//import net.minecraft.village.MerchantRecipeList;
|
||||
//
|
||||
//public class BasicTradeList implements ITradeList {
|
||||
//
|
||||
// private final ItemStack input;
|
||||
// private final PriceInfo inputAmount;
|
||||
// private final ItemStack output;
|
||||
// private final PriceInfo outputAmount;
|
||||
//
|
||||
// public BasicTradeList(ItemStack input, PriceInfo inputAmount, ItemStack output, PriceInfo outputAmount) {
|
||||
// this.input = input;
|
||||
// this.inputAmount = inputAmount;
|
||||
// this.output = output;
|
||||
// this.outputAmount = outputAmount;
|
||||
// }
|
||||
//
|
||||
// public BasicTradeList(PriceInfo emeraldInput, ItemStack output, PriceInfo outputAmount) {
|
||||
// this(new ItemStack(Items.EMERALD), emeraldInput, output, outputAmount);
|
||||
// }
|
||||
//
|
||||
// public BasicTradeList(ItemStack input, PriceInfo inputAmount, PriceInfo emeraldOutput) {
|
||||
// this(input, inputAmount, new ItemStack(Items.EMERALD), emeraldOutput);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void addMerchantRecipe(IMerchant merchant, MerchantRecipeList recipeList, Random random) {
|
||||
// ItemStack in = this.input.copy();
|
||||
// in.setCount(this.inputAmount.getPrice(random));
|
||||
// ItemStack out = this.output.copy();
|
||||
// out.setCount(this.outputAmount.getPrice(random));
|
||||
// recipeList.add(new MerchantRecipe(in, out));
|
||||
// }
|
||||
//}
|
||||
|
|
|
@ -1,116 +1,116 @@
|
|||
/*
|
||||
* This file ("VillageComponentCustomCropField.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2017 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.gen.village.component;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockCrops;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.structure.StructureBoundingBox;
|
||||
import net.minecraft.world.gen.structure.StructureComponent;
|
||||
import net.minecraft.world.gen.structure.StructureVillagePieces;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class VillageComponentCustomCropField extends StructureVillagePieces.House1 {
|
||||
|
||||
private static final int X_SIZE = 13;
|
||||
private static final int Y_SIZE = 4;
|
||||
private static final int Z_SIZE = 9;
|
||||
|
||||
private int averageGroundLevel = -1;
|
||||
|
||||
public VillageComponentCustomCropField() {
|
||||
|
||||
}
|
||||
|
||||
public VillageComponentCustomCropField(StructureBoundingBox boundingBox, Direction par5) {
|
||||
this.setCoordBaseMode(par5);
|
||||
this.boundingBox = boundingBox;
|
||||
}
|
||||
|
||||
public static VillageComponentCustomCropField buildComponent(List<StructureComponent> pieces, int p1, int p2, int p3, Direction p4) {
|
||||
StructureBoundingBox boundingBox = StructureBoundingBox.getComponentToAddBoundingBox(p1, p2, p3, 0, 0, 0, X_SIZE, Y_SIZE, Z_SIZE, p4);
|
||||
return canVillageGoDeeper(boundingBox) && StructureComponent.findIntersecting(pieces, boundingBox) == null
|
||||
? new VillageComponentCustomCropField(boundingBox, p4)
|
||||
: null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addComponentParts(World world, Random rand, StructureBoundingBox sbb) {
|
||||
if (this.averageGroundLevel < 0) {
|
||||
this.averageGroundLevel = this.getAverageGroundLevel(world, sbb);
|
||||
if (this.averageGroundLevel < 0) {
|
||||
return true;
|
||||
}
|
||||
this.boundingBox.offset(0, this.averageGroundLevel - this.boundingBox.maxY + Y_SIZE - 1, 0);
|
||||
}
|
||||
|
||||
this.fillWithBlocks(world, sbb, 0, 0, 0, X_SIZE - 1, Y_SIZE - 1, Z_SIZE - 1, Blocks.AIR);
|
||||
this.spawnActualHouse(world, rand, sbb);
|
||||
|
||||
for (int i = 0; i < X_SIZE; i++) {
|
||||
for (int j = 0; j < Z_SIZE; j++) {
|
||||
this.clearCurrentPositionBlocksUpwards(world, i, Y_SIZE, j, sbb);
|
||||
this.replaceAirAndLiquidDownwards(world, Blocks.DIRT.getDefaultState(), i, -1, j, sbb);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void fillWithBlocks(World world, StructureBoundingBox sbb, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, Block block) {
|
||||
this.fillWithBlocks(world, sbb, minX, minY, minZ, maxX, maxY, maxZ, block.getDefaultState(), block.getDefaultState(), false);
|
||||
}
|
||||
|
||||
public void spawnActualHouse(World world, Random rand, StructureBoundingBox sbb) {
|
||||
this.fillWithBlocks(world, sbb, 1, 0, 1, 2, 0, 7, Blocks.FARMLAND);
|
||||
this.fillWithBlocks(world, sbb, 4, 0, 1, 5, 0, 7, Blocks.FARMLAND);
|
||||
this.fillWithBlocks(world, sbb, 7, 0, 1, 8, 0, 7, Blocks.FARMLAND);
|
||||
this.fillWithBlocks(world, sbb, 10, 0, 1, 11, 0, 7, Blocks.FARMLAND);
|
||||
this.fillWithBlocks(world, sbb, 0, 0, 0, 0, 0, 8, Blocks.LOG);
|
||||
this.fillWithBlocks(world, sbb, 6, 0, 0, 6, 0, 8, Blocks.LOG);
|
||||
this.fillWithBlocks(world, sbb, 12, 0, 0, 12, 0, 8, Blocks.LOG);
|
||||
this.fillWithBlocks(world, sbb, 1, 0, 0, 11, 0, 0, Blocks.LOG);
|
||||
this.fillWithBlocks(world, sbb, 1, 0, 8, 11, 0, 8, Blocks.LOG);
|
||||
this.fillWithBlocks(world, sbb, 3, 0, 1, 3, 0, 7, Blocks.WATER);
|
||||
this.fillWithBlocks(world, sbb, 9, 0, 1, 9, 0, 7, Blocks.WATER);
|
||||
|
||||
for (int i = 1; i <= 7; ++i) {
|
||||
this.setBlockState(world, this.getRandomCropType(rand), 1, 1, i, sbb);
|
||||
this.setBlockState(world, this.getRandomCropType(rand), 2, 1, i, sbb);
|
||||
this.setBlockState(world, this.getRandomCropType(rand), 4, 1, i, sbb);
|
||||
this.setBlockState(world, this.getRandomCropType(rand), 5, 1, i, sbb);
|
||||
this.setBlockState(world, this.getRandomCropType(rand), 7, 1, i, sbb);
|
||||
this.setBlockState(world, this.getRandomCropType(rand), 8, 1, i, sbb);
|
||||
this.setBlockState(world, this.getRandomCropType(rand), 10, 1, i, sbb);
|
||||
this.setBlockState(world, this.getRandomCropType(rand), 11, 1, i, sbb);
|
||||
}
|
||||
}
|
||||
|
||||
private BlockState getRandomCropType(Random rand) {
|
||||
int randomMeta = MathHelper.getInt(rand, 1, 7);
|
||||
switch (rand.nextInt(4)) {
|
||||
case 0:
|
||||
return ActuallyBlocks.blockFlax.getDefaultState().withProperty(BlockCrops.AGE, randomMeta);
|
||||
case 1:
|
||||
return ActuallyBlocks.blockCoffee.getDefaultState().withProperty(BlockCrops.AGE, randomMeta);
|
||||
case 2:
|
||||
return ActuallyBlocks.blockRice.getDefaultState().withProperty(BlockCrops.AGE, randomMeta);
|
||||
default:
|
||||
return ActuallyBlocks.blockCanola.getDefaultState().withProperty(BlockCrops.AGE, randomMeta);
|
||||
}
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * This file ("VillageComponentCustomCropField.java") is part of the Actually Additions mod for Minecraft.
|
||||
// * It is created and owned by Ellpeck and distributed
|
||||
// * under the Actually Additions License to be found at
|
||||
// * http://ellpeck.de/actaddlicense
|
||||
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
// *
|
||||
// * © 2015-2017 Ellpeck
|
||||
// */
|
||||
//
|
||||
//package de.ellpeck.actuallyadditions.mod.gen.village.component;
|
||||
//
|
||||
//import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||
//import net.minecraft.block.Block;
|
||||
//import net.minecraft.block.BlockCrops;
|
||||
//import net.minecraft.init.Blocks;
|
||||
//import net.minecraft.util.Direction;
|
||||
//import net.minecraft.util.math.MathHelper;
|
||||
//import net.minecraft.world.World;
|
||||
//import net.minecraft.world.gen.structure.StructureBoundingBox;
|
||||
//import net.minecraft.world.gen.structure.StructureComponent;
|
||||
//import net.minecraft.world.gen.structure.StructureVillagePieces;
|
||||
//
|
||||
//import java.util.List;
|
||||
//import java.util.Random;
|
||||
//
|
||||
//public class VillageComponentCustomCropField extends StructureVillagePieces.House1 {
|
||||
//
|
||||
// private static final int X_SIZE = 13;
|
||||
// private static final int Y_SIZE = 4;
|
||||
// private static final int Z_SIZE = 9;
|
||||
//
|
||||
// private int averageGroundLevel = -1;
|
||||
//
|
||||
// public VillageComponentCustomCropField() {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public VillageComponentCustomCropField(StructureBoundingBox boundingBox, Direction par5) {
|
||||
// this.setCoordBaseMode(par5);
|
||||
// this.boundingBox = boundingBox;
|
||||
// }
|
||||
//
|
||||
// public static VillageComponentCustomCropField buildComponent(List<StructureComponent> pieces, int p1, int p2, int p3, Direction p4) {
|
||||
// StructureBoundingBox boundingBox = StructureBoundingBox.getComponentToAddBoundingBox(p1, p2, p3, 0, 0, 0, X_SIZE, Y_SIZE, Z_SIZE, p4);
|
||||
// return canVillageGoDeeper(boundingBox) && StructureComponent.findIntersecting(pieces, boundingBox) == null
|
||||
// ? new VillageComponentCustomCropField(boundingBox, p4)
|
||||
// : null;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean addComponentParts(World world, Random rand, StructureBoundingBox sbb) {
|
||||
// if (this.averageGroundLevel < 0) {
|
||||
// this.averageGroundLevel = this.getAverageGroundLevel(world, sbb);
|
||||
// if (this.averageGroundLevel < 0) {
|
||||
// return true;
|
||||
// }
|
||||
// this.boundingBox.offset(0, this.averageGroundLevel - this.boundingBox.maxY + Y_SIZE - 1, 0);
|
||||
// }
|
||||
//
|
||||
// this.fillWithBlocks(world, sbb, 0, 0, 0, X_SIZE - 1, Y_SIZE - 1, Z_SIZE - 1, Blocks.AIR);
|
||||
// this.spawnActualHouse(world, rand, sbb);
|
||||
//
|
||||
// for (int i = 0; i < X_SIZE; i++) {
|
||||
// for (int j = 0; j < Z_SIZE; j++) {
|
||||
// this.clearCurrentPositionBlocksUpwards(world, i, Y_SIZE, j, sbb);
|
||||
// this.replaceAirAndLiquidDownwards(world, Blocks.DIRT.getDefaultState(), i, -1, j, sbb);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// public void fillWithBlocks(World world, StructureBoundingBox sbb, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, Block block) {
|
||||
// this.fillWithBlocks(world, sbb, minX, minY, minZ, maxX, maxY, maxZ, block.getDefaultState(), block.getDefaultState(), false);
|
||||
// }
|
||||
//
|
||||
// public void spawnActualHouse(World world, Random rand, StructureBoundingBox sbb) {
|
||||
// this.fillWithBlocks(world, sbb, 1, 0, 1, 2, 0, 7, Blocks.FARMLAND);
|
||||
// this.fillWithBlocks(world, sbb, 4, 0, 1, 5, 0, 7, Blocks.FARMLAND);
|
||||
// this.fillWithBlocks(world, sbb, 7, 0, 1, 8, 0, 7, Blocks.FARMLAND);
|
||||
// this.fillWithBlocks(world, sbb, 10, 0, 1, 11, 0, 7, Blocks.FARMLAND);
|
||||
// this.fillWithBlocks(world, sbb, 0, 0, 0, 0, 0, 8, Blocks.LOG);
|
||||
// this.fillWithBlocks(world, sbb, 6, 0, 0, 6, 0, 8, Blocks.LOG);
|
||||
// this.fillWithBlocks(world, sbb, 12, 0, 0, 12, 0, 8, Blocks.LOG);
|
||||
// this.fillWithBlocks(world, sbb, 1, 0, 0, 11, 0, 0, Blocks.LOG);
|
||||
// this.fillWithBlocks(world, sbb, 1, 0, 8, 11, 0, 8, Blocks.LOG);
|
||||
// this.fillWithBlocks(world, sbb, 3, 0, 1, 3, 0, 7, Blocks.WATER);
|
||||
// this.fillWithBlocks(world, sbb, 9, 0, 1, 9, 0, 7, Blocks.WATER);
|
||||
//
|
||||
// for (int i = 1; i <= 7; ++i) {
|
||||
// this.setBlockState(world, this.getRandomCropType(rand), 1, 1, i, sbb);
|
||||
// this.setBlockState(world, this.getRandomCropType(rand), 2, 1, i, sbb);
|
||||
// this.setBlockState(world, this.getRandomCropType(rand), 4, 1, i, sbb);
|
||||
// this.setBlockState(world, this.getRandomCropType(rand), 5, 1, i, sbb);
|
||||
// this.setBlockState(world, this.getRandomCropType(rand), 7, 1, i, sbb);
|
||||
// this.setBlockState(world, this.getRandomCropType(rand), 8, 1, i, sbb);
|
||||
// this.setBlockState(world, this.getRandomCropType(rand), 10, 1, i, sbb);
|
||||
// this.setBlockState(world, this.getRandomCropType(rand), 11, 1, i, sbb);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private BlockState getRandomCropType(Random rand) {
|
||||
// int randomMeta = MathHelper.getInt(rand, 1, 7);
|
||||
// switch (rand.nextInt(4)) {
|
||||
// case 0:
|
||||
// return ActuallyBlocks.blockFlax.getDefaultState().withProperty(BlockCrops.AGE, randomMeta);
|
||||
// case 1:
|
||||
// return ActuallyBlocks.blockCoffee.getDefaultState().withProperty(BlockCrops.AGE, randomMeta);
|
||||
// case 2:
|
||||
// return ActuallyBlocks.blockRice.getDefaultState().withProperty(BlockCrops.AGE, randomMeta);
|
||||
// default:
|
||||
// return ActuallyBlocks.blockCanola.getDefaultState().withProperty(BlockCrops.AGE, randomMeta);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
|
|
@ -1,220 +1,220 @@
|
|||
/*
|
||||
* This file ("VillageComponentEngineerHouse.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2017 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.gen.village.component;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.laser.LaserType;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.BlockColoredLamp;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheColoredLampColors;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
|
||||
import de.ellpeck.actuallyadditions.mod.gen.village.InitVillager;
|
||||
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
||||
import de.ellpeck.actuallyadditions.mod.misc.DungeonLoot;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.*;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.merchant.villager.VillagerProfession;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Mirror;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Rotation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.feature.template.PlacementSettings;
|
||||
import net.minecraft.world.gen.feature.template.Template;
|
||||
import net.minecraft.world.gen.feature.template.TemplateManager;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class VillageComponentEngineerHouse extends StructureVillagePieces.House1 {
|
||||
|
||||
private static final ResourceLocation STRUCTURE_RES_LOC = new ResourceLocation(ActuallyAdditions.MODID, "andrew_period_house");
|
||||
|
||||
private static final int X_SIZE = 13;
|
||||
private static final int Y_SIZE = 11;
|
||||
private static final int Z_SIZE = 10;
|
||||
|
||||
private int averageGroundLevel = -1;
|
||||
|
||||
public VillageComponentEngineerHouse() {
|
||||
|
||||
}
|
||||
|
||||
public VillageComponentEngineerHouse(StructureBoundingBox boundingBox, Direction par5) {
|
||||
this.setCoordBaseMode(par5);
|
||||
this.boundingBox = boundingBox;
|
||||
}
|
||||
|
||||
public static VillageComponentEngineerHouse buildComponent(List<StructureComponent> pieces, int p1, int p2, int p3, Direction p4) {
|
||||
StructureBoundingBox boundingBox = StructureBoundingBox.getComponentToAddBoundingBox(p1, p2, p3, 0, 0, 0, X_SIZE, Y_SIZE, Z_SIZE, p4);
|
||||
return canVillageGoDeeper(boundingBox) && StructureComponent.findIntersecting(pieces, boundingBox) == null
|
||||
? new VillageComponentEngineerHouse(boundingBox, p4)
|
||||
: null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addComponentParts(World world, Random rand, StructureBoundingBox sbb) {
|
||||
if (this.averageGroundLevel < 0) {
|
||||
this.averageGroundLevel = this.getAverageGroundLevel(world, sbb);
|
||||
if (this.averageGroundLevel < 0) {
|
||||
return true;
|
||||
}
|
||||
this.boundingBox.offset(0, this.averageGroundLevel - this.boundingBox.maxY + Y_SIZE - 2, 0);
|
||||
}
|
||||
|
||||
this.fillWithBlocks(world, sbb, 0, 0, 0, X_SIZE - 1, Y_SIZE - 1, Z_SIZE - 1, Blocks.AIR);
|
||||
this.spawnActualHouse(world, sbb);
|
||||
this.fillHouse(world, sbb);
|
||||
|
||||
for (int i = 0; i < X_SIZE; i++) {
|
||||
for (int j = 0; j < Z_SIZE; j++) {
|
||||
this.clearCurrentPositionBlocksUpwards(world, i, Y_SIZE, j, sbb);
|
||||
this.replaceAirAndLiquidDownwards(world, Blocks.DIRT.getDefaultState(), i, -1, j, sbb);
|
||||
}
|
||||
}
|
||||
|
||||
this.spawnVillagers(world, sbb, 7, 4, 6, 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void fillWithBlocks(World world, StructureBoundingBox sbb, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, Block block) {
|
||||
this.fillWithBlocks(world, sbb, minX, minY, minZ, maxX, maxY, maxZ, block.getDefaultState(), block.getDefaultState(), false);
|
||||
}
|
||||
|
||||
private void fillHouse(World world, StructureBoundingBox sbb) {
|
||||
if (ConfigBoolValues.DUNGEON_LOOT.isEnabled()) {
|
||||
if (world.rand.nextBoolean()) {
|
||||
TileEntity compost = this.getTileAtPos(world, 6, 1, 2, sbb);
|
||||
if (compost instanceof TileEntityCompost) {
|
||||
TileEntityCompost tile = (TileEntityCompost) compost;
|
||||
tile.stopFromDropping = true;
|
||||
tile.inv.setStackInSlot(0, new ItemStack(ActuallyItems.itemFertilizer, 10));
|
||||
}
|
||||
}
|
||||
|
||||
TileEntity ferment = this.getTileAtPos(world, 11, 1, 0, sbb);
|
||||
if (ferment instanceof TileEntityFermentingBarrel) {
|
||||
TileEntityFermentingBarrel tile = (TileEntityFermentingBarrel) ferment;
|
||||
tile.stopFromDropping = true;
|
||||
tile.canolaTank.setFluid(new FluidStack(InitFluids.fluidCanolaOil, world.rand.nextInt(1500) + 200));
|
||||
}
|
||||
|
||||
TileEntity coffee = this.getTileAtPos(world, 4, 2, 6, sbb);
|
||||
if (coffee instanceof TileEntityCoffeeMachine) {
|
||||
TileEntityCoffeeMachine tile = (TileEntityCoffeeMachine) coffee;
|
||||
tile.stopFromDropping = true;
|
||||
tile.tank.setFluid(new FluidStack(FluidRegistry.WATER, world.rand.nextInt(3000) + 500));
|
||||
tile.coffeeCacheAmount = world.rand.nextInt(150);
|
||||
tile.storage.setEnergyStored(world.rand.nextInt(tile.storage.getMaxEnergyStored() / 2));
|
||||
}
|
||||
|
||||
TileEntity press = this.getTileAtPos(world, 2, 1, 5, sbb);
|
||||
if (press instanceof TileEntityCanolaPress) {
|
||||
TileEntityCanolaPress tile = (TileEntityCanolaPress) press;
|
||||
tile.stopFromDropping = true;
|
||||
tile.storage.setEnergyStored(world.rand.nextInt(tile.storage.getMaxEnergyStored() / 3));
|
||||
tile.inv.setStackInSlot(0, new ItemStack(ActuallyItems.itemCanola.get(), world.rand.nextInt(60) + 1));
|
||||
}
|
||||
|
||||
TileEntity crusher = this.getTileAtPos(world, 2, 1, 6, sbb);
|
||||
if (crusher instanceof TileEntityGrinder) {
|
||||
TileEntityGrinder tile = (TileEntityGrinder) crusher;
|
||||
tile.stopFromDropping = true;
|
||||
tile.storage.setEnergyStored(world.rand.nextInt(tile.storage.getMaxEnergyStored() / 2));
|
||||
if (world.rand.nextFloat() >= 0.25F) {
|
||||
tile.inv.setStackInSlot(TileEntityGrinder.SLOT_INPUT_1, new ItemStack(ActuallyBlocks.blockMisc, world.rand.nextInt(10) + 1, TheMiscBlocks.ORE_QUARTZ.ordinal()));
|
||||
}
|
||||
}
|
||||
|
||||
TileEntity coal = this.getTileAtPos(world, 5, 5, 6, sbb);
|
||||
if (coal instanceof TileEntityCoalGenerator) {
|
||||
TileEntityCoalGenerator tile = (TileEntityCoalGenerator) coal;
|
||||
tile.stopFromDropping = true;
|
||||
tile.inv.setStackInSlot(0, new ItemStack(Items.COAL, world.rand.nextInt(25) + 3, 1));
|
||||
}
|
||||
|
||||
TileEntity reconstructor = this.getTileAtPos(world, 8, 4, 3, sbb);
|
||||
if (reconstructor instanceof TileEntityAtomicReconstructor) {
|
||||
((TileEntityAtomicReconstructor) reconstructor).stopFromDropping = true;
|
||||
}
|
||||
|
||||
VillageComponentJamHouse.generateCrate(world, sbb, this.getXWithOffset(6, 4), this.getYWithOffset(4), this.getZWithOffset(6, 4), DungeonLoot.ENGINEER_HOUSE);
|
||||
}
|
||||
|
||||
TileEntity firstRelay = this.getTileAtPos(world, 6, 5, 6, sbb);
|
||||
TileEntity secondRelay = this.getTileAtPos(world, 8, 5, 3, sbb);
|
||||
if (firstRelay instanceof TileEntityLaserRelayEnergy && secondRelay instanceof TileEntityLaserRelayEnergy) {
|
||||
((TileEntityLaserRelayEnergy) firstRelay).stopFromDropping = true;
|
||||
((TileEntityLaserRelayEnergy) secondRelay).stopFromDropping = true;
|
||||
ActuallyAdditionsAPI.connectionHandler.addConnection(firstRelay.getPos(), secondRelay.getPos(), LaserType.ENERGY, world);
|
||||
}
|
||||
|
||||
int meta = world.rand.nextInt(TheColoredLampColors.values().length);
|
||||
this.setBlockState(world, ActuallyBlocks.blockColoredLampOn.getDefaultState().withProperty(BlockColoredLamp.TYPE, BlockColoredLamp.ALL_LAMP_TYPES[meta]), 8, 1, 6, sbb);
|
||||
}
|
||||
|
||||
private void spawnActualHouse(World world, StructureBoundingBox sbb) {
|
||||
TemplateManager manager = world.getSaveHandler().getStructureTemplateManager();
|
||||
MinecraftServer server = world.getMinecraftServer();
|
||||
|
||||
if (manager != null && server != null) {
|
||||
Direction facing = this.getCoordBaseMode();
|
||||
|
||||
Mirror mirror;
|
||||
Rotation rotation;
|
||||
if (facing == Direction.SOUTH) {
|
||||
mirror = Mirror.NONE;
|
||||
rotation = Rotation.NONE;
|
||||
} else if (facing == Direction.WEST) {
|
||||
mirror = Mirror.NONE;
|
||||
rotation = Rotation.CLOCKWISE_90;
|
||||
} else if (facing == Direction.EAST) {
|
||||
mirror = Mirror.LEFT_RIGHT;
|
||||
rotation = Rotation.CLOCKWISE_90;
|
||||
} else {
|
||||
mirror = Mirror.LEFT_RIGHT;
|
||||
rotation = Rotation.NONE;
|
||||
}
|
||||
|
||||
PlacementSettings placement = new PlacementSettings().setRotation(rotation).setMirror(mirror).setBoundingBox(sbb);
|
||||
Template template = manager.getTemplate(server, STRUCTURE_RES_LOC);
|
||||
|
||||
if (template != null) {
|
||||
template.addBlocksToWorld(world, new BlockPos(this.getXWithOffset(0, 0), this.getYWithOffset(0), this.getZWithOffset(0, 0)), placement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private TileEntity getTileAtPos(World world, int x, int y, int z, StructureBoundingBox sbb) {
|
||||
BlockPos pos = new BlockPos(this.getXWithOffset(x, z), this.getYWithOffset(y), this.getZWithOffset(x, z));
|
||||
if (sbb.isVecInside(pos)) {
|
||||
return world.getTileEntity(pos);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected VillagerProfession chooseForgeProfession(int count, VillagerProfession prof) {
|
||||
return InitVillager.engineerProfession;
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * This file ("VillageComponentEngineerHouse.java") is part of the Actually Additions mod for Minecraft.
|
||||
// * It is created and owned by Ellpeck and distributed
|
||||
// * under the Actually Additions License to be found at
|
||||
// * http://ellpeck.de/actaddlicense
|
||||
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
// *
|
||||
// * © 2015-2017 Ellpeck
|
||||
// */
|
||||
//
|
||||
//package de.ellpeck.actuallyadditions.mod.gen.village.component;
|
||||
//
|
||||
//import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
//import de.ellpeck.actuallyadditions.api.laser.LaserType;
|
||||
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
//import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||
//import de.ellpeck.actuallyadditions.mod.blocks.BlockColoredLamp;
|
||||
//import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheColoredLampColors;
|
||||
//import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks;
|
||||
//import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||
//import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
|
||||
//import de.ellpeck.actuallyadditions.mod.gen.village.InitVillager;
|
||||
//import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
||||
//import de.ellpeck.actuallyadditions.mod.misc.DungeonLoot;
|
||||
//import de.ellpeck.actuallyadditions.mod.tile.*;
|
||||
//import net.minecraft.block.Block;
|
||||
//import net.minecraft.block.Blocks;
|
||||
//import net.minecraft.entity.merchant.villager.VillagerProfession;
|
||||
//import net.minecraft.item.ItemStack;
|
||||
//import net.minecraft.item.Items;
|
||||
//import net.minecraft.server.MinecraftServer;
|
||||
//import net.minecraft.tileentity.TileEntity;
|
||||
//import net.minecraft.util.Direction;
|
||||
//import net.minecraft.util.Mirror;
|
||||
//import net.minecraft.util.ResourceLocation;
|
||||
//import net.minecraft.util.Rotation;
|
||||
//import net.minecraft.util.math.BlockPos;
|
||||
//import net.minecraft.world.World;
|
||||
//import net.minecraft.world.gen.feature.template.PlacementSettings;
|
||||
//import net.minecraft.world.gen.feature.template.Template;
|
||||
//import net.minecraft.world.gen.feature.template.TemplateManager;
|
||||
//import net.minecraftforge.fluids.FluidStack;
|
||||
//
|
||||
//import java.util.List;
|
||||
//import java.util.Random;
|
||||
//
|
||||
//public class VillageComponentEngineerHouse extends StructureVillagePieces.House1 {
|
||||
//
|
||||
// private static final ResourceLocation STRUCTURE_RES_LOC = new ResourceLocation(ActuallyAdditions.MODID, "andrew_period_house");
|
||||
//
|
||||
// private static final int X_SIZE = 13;
|
||||
// private static final int Y_SIZE = 11;
|
||||
// private static final int Z_SIZE = 10;
|
||||
//
|
||||
// private int averageGroundLevel = -1;
|
||||
//
|
||||
// public VillageComponentEngineerHouse() {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public VillageComponentEngineerHouse(StructureBoundingBox boundingBox, Direction par5) {
|
||||
// this.setCoordBaseMode(par5);
|
||||
// this.boundingBox = boundingBox;
|
||||
// }
|
||||
//
|
||||
// public static VillageComponentEngineerHouse buildComponent(List<StructureComponent> pieces, int p1, int p2, int p3, Direction p4) {
|
||||
// StructureBoundingBox boundingBox = StructureBoundingBox.getComponentToAddBoundingBox(p1, p2, p3, 0, 0, 0, X_SIZE, Y_SIZE, Z_SIZE, p4);
|
||||
// return canVillageGoDeeper(boundingBox) && StructureComponent.findIntersecting(pieces, boundingBox) == null
|
||||
// ? new VillageComponentEngineerHouse(boundingBox, p4)
|
||||
// : null;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean addComponentParts(World world, Random rand, StructureBoundingBox sbb) {
|
||||
// if (this.averageGroundLevel < 0) {
|
||||
// this.averageGroundLevel = this.getAverageGroundLevel(world, sbb);
|
||||
// if (this.averageGroundLevel < 0) {
|
||||
// return true;
|
||||
// }
|
||||
// this.boundingBox.offset(0, this.averageGroundLevel - this.boundingBox.maxY + Y_SIZE - 2, 0);
|
||||
// }
|
||||
//
|
||||
// this.fillWithBlocks(world, sbb, 0, 0, 0, X_SIZE - 1, Y_SIZE - 1, Z_SIZE - 1, Blocks.AIR);
|
||||
// this.spawnActualHouse(world, sbb);
|
||||
// this.fillHouse(world, sbb);
|
||||
//
|
||||
// for (int i = 0; i < X_SIZE; i++) {
|
||||
// for (int j = 0; j < Z_SIZE; j++) {
|
||||
// this.clearCurrentPositionBlocksUpwards(world, i, Y_SIZE, j, sbb);
|
||||
// this.replaceAirAndLiquidDownwards(world, Blocks.DIRT.getDefaultState(), i, -1, j, sbb);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// this.spawnVillagers(world, sbb, 7, 4, 6, 1);
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// private void fillWithBlocks(World world, StructureBoundingBox sbb, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, Block block) {
|
||||
// this.fillWithBlocks(world, sbb, minX, minY, minZ, maxX, maxY, maxZ, block.getDefaultState(), block.getDefaultState(), false);
|
||||
// }
|
||||
//
|
||||
// private void fillHouse(World world, StructureBoundingBox sbb) {
|
||||
// if (ConfigBoolValues.DUNGEON_LOOT.isEnabled()) {
|
||||
// if (world.rand.nextBoolean()) {
|
||||
// TileEntity compost = this.getTileAtPos(world, 6, 1, 2, sbb);
|
||||
// if (compost instanceof TileEntityCompost) {
|
||||
// TileEntityCompost tile = (TileEntityCompost) compost;
|
||||
// tile.stopFromDropping = true;
|
||||
// tile.inv.setStackInSlot(0, new ItemStack(ActuallyItems.itemFertilizer, 10));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// TileEntity ferment = this.getTileAtPos(world, 11, 1, 0, sbb);
|
||||
// if (ferment instanceof TileEntityFermentingBarrel) {
|
||||
// TileEntityFermentingBarrel tile = (TileEntityFermentingBarrel) ferment;
|
||||
// tile.stopFromDropping = true;
|
||||
// tile.canolaTank.setFluid(new FluidStack(InitFluids.fluidCanolaOil, world.rand.nextInt(1500) + 200));
|
||||
// }
|
||||
//
|
||||
// TileEntity coffee = this.getTileAtPos(world, 4, 2, 6, sbb);
|
||||
// if (coffee instanceof TileEntityCoffeeMachine) {
|
||||
// TileEntityCoffeeMachine tile = (TileEntityCoffeeMachine) coffee;
|
||||
// tile.stopFromDropping = true;
|
||||
// tile.tank.setFluid(new FluidStack(FluidRegistry.WATER, world.rand.nextInt(3000) + 500));
|
||||
// tile.coffeeCacheAmount = world.rand.nextInt(150);
|
||||
// tile.storage.setEnergyStored(world.rand.nextInt(tile.storage.getMaxEnergyStored() / 2));
|
||||
// }
|
||||
//
|
||||
// TileEntity press = this.getTileAtPos(world, 2, 1, 5, sbb);
|
||||
// if (press instanceof TileEntityCanolaPress) {
|
||||
// TileEntityCanolaPress tile = (TileEntityCanolaPress) press;
|
||||
// tile.stopFromDropping = true;
|
||||
// tile.storage.setEnergyStored(world.rand.nextInt(tile.storage.getMaxEnergyStored() / 3));
|
||||
// tile.inv.setStackInSlot(0, new ItemStack(ActuallyItems.itemCanola.get(), world.rand.nextInt(60) + 1));
|
||||
// }
|
||||
//
|
||||
// TileEntity crusher = this.getTileAtPos(world, 2, 1, 6, sbb);
|
||||
// if (crusher instanceof TileEntityGrinder) {
|
||||
// TileEntityGrinder tile = (TileEntityGrinder) crusher;
|
||||
// tile.stopFromDropping = true;
|
||||
// tile.storage.setEnergyStored(world.rand.nextInt(tile.storage.getMaxEnergyStored() / 2));
|
||||
// if (world.rand.nextFloat() >= 0.25F) {
|
||||
// tile.inv.setStackInSlot(TileEntityGrinder.SLOT_INPUT_1, new ItemStack(ActuallyBlocks.blockMisc, world.rand.nextInt(10) + 1, TheMiscBlocks.ORE_QUARTZ.ordinal()));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// TileEntity coal = this.getTileAtPos(world, 5, 5, 6, sbb);
|
||||
// if (coal instanceof TileEntityCoalGenerator) {
|
||||
// TileEntityCoalGenerator tile = (TileEntityCoalGenerator) coal;
|
||||
// tile.stopFromDropping = true;
|
||||
// tile.inv.setStackInSlot(0, new ItemStack(Items.COAL, world.rand.nextInt(25) + 3, 1));
|
||||
// }
|
||||
//
|
||||
// TileEntity reconstructor = this.getTileAtPos(world, 8, 4, 3, sbb);
|
||||
// if (reconstructor instanceof TileEntityAtomicReconstructor) {
|
||||
// ((TileEntityAtomicReconstructor) reconstructor).stopFromDropping = true;
|
||||
// }
|
||||
//
|
||||
// VillageComponentJamHouse.generateCrate(world, sbb, this.getXWithOffset(6, 4), this.getYWithOffset(4), this.getZWithOffset(6, 4), DungeonLoot.ENGINEER_HOUSE);
|
||||
// }
|
||||
//
|
||||
// TileEntity firstRelay = this.getTileAtPos(world, 6, 5, 6, sbb);
|
||||
// TileEntity secondRelay = this.getTileAtPos(world, 8, 5, 3, sbb);
|
||||
// if (firstRelay instanceof TileEntityLaserRelayEnergy && secondRelay instanceof TileEntityLaserRelayEnergy) {
|
||||
// ((TileEntityLaserRelayEnergy) firstRelay).stopFromDropping = true;
|
||||
// ((TileEntityLaserRelayEnergy) secondRelay).stopFromDropping = true;
|
||||
// ActuallyAdditionsAPI.connectionHandler.addConnection(firstRelay.getPos(), secondRelay.getPos(), LaserType.ENERGY, world);
|
||||
// }
|
||||
//
|
||||
// int meta = world.rand.nextInt(TheColoredLampColors.values().length);
|
||||
// this.setBlockState(world, ActuallyBlocks.blockColoredLampOn.getDefaultState().withProperty(BlockColoredLamp.TYPE, BlockColoredLamp.ALL_LAMP_TYPES[meta]), 8, 1, 6, sbb);
|
||||
// }
|
||||
//
|
||||
// private void spawnActualHouse(World world, StructureBoundingBox sbb) {
|
||||
// TemplateManager manager = world.getSaveHandler().getStructureTemplateManager();
|
||||
// MinecraftServer server = world.getMinecraftServer();
|
||||
//
|
||||
// if (manager != null && server != null) {
|
||||
// Direction facing = this.getCoordBaseMode();
|
||||
//
|
||||
// Mirror mirror;
|
||||
// Rotation rotation;
|
||||
// if (facing == Direction.SOUTH) {
|
||||
// mirror = Mirror.NONE;
|
||||
// rotation = Rotation.NONE;
|
||||
// } else if (facing == Direction.WEST) {
|
||||
// mirror = Mirror.NONE;
|
||||
// rotation = Rotation.CLOCKWISE_90;
|
||||
// } else if (facing == Direction.EAST) {
|
||||
// mirror = Mirror.LEFT_RIGHT;
|
||||
// rotation = Rotation.CLOCKWISE_90;
|
||||
// } else {
|
||||
// mirror = Mirror.LEFT_RIGHT;
|
||||
// rotation = Rotation.NONE;
|
||||
// }
|
||||
//
|
||||
// PlacementSettings placement = new PlacementSettings().setRotation(rotation).setMirror(mirror).setBoundingBox(sbb);
|
||||
// Template template = manager.getTemplate(server, STRUCTURE_RES_LOC);
|
||||
//
|
||||
// if (template != null) {
|
||||
// template.addBlocksToWorld(world, new BlockPos(this.getXWithOffset(0, 0), this.getYWithOffset(0), this.getZWithOffset(0, 0)), placement);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private TileEntity getTileAtPos(World world, int x, int y, int z, StructureBoundingBox sbb) {
|
||||
// BlockPos pos = new BlockPos(this.getXWithOffset(x, z), this.getYWithOffset(y), this.getZWithOffset(x, z));
|
||||
// if (sbb.isVecInside(pos)) {
|
||||
// return world.getTileEntity(pos);
|
||||
// } else {
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected VillagerProfession chooseForgeProfession(int count, VillagerProfession prof) {
|
||||
// return InitVillager.engineerProfession;
|
||||
// }
|
||||
//}
|
||||
|
|
|
@ -1,232 +1,232 @@
|
|||
/*
|
||||
* This file ("VillageComponentJamHouse.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2017 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.gen.village.component;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||
import de.ellpeck.actuallyadditions.mod.gen.village.InitVillager;
|
||||
import de.ellpeck.actuallyadditions.mod.misc.DungeonLoot;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChest;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.structure.StructureBoundingBox;
|
||||
import net.minecraft.world.gen.structure.StructureComponent;
|
||||
import net.minecraft.world.gen.structure.StructureVillagePieces;
|
||||
import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class VillageComponentJamHouse extends StructureVillagePieces.House1 {
|
||||
|
||||
private static final int X_SIZE = 11;
|
||||
private static final int Y_SIZE = 8;
|
||||
private static final int Z_SIZE = 12;
|
||||
|
||||
private int averageGroundLevel = -1;
|
||||
|
||||
public VillageComponentJamHouse() {
|
||||
|
||||
}
|
||||
|
||||
public VillageComponentJamHouse(StructureBoundingBox boundingBox, Direction par5) {
|
||||
this.setCoordBaseMode(par5);
|
||||
this.boundingBox = boundingBox;
|
||||
}
|
||||
|
||||
public static VillageComponentJamHouse buildComponent(List<StructureComponent> pieces, int p1, int p2, int p3, Direction p4) {
|
||||
StructureBoundingBox boundingBox = StructureBoundingBox.getComponentToAddBoundingBox(p1, p2, p3, 0, 0, 0, X_SIZE, Y_SIZE, Z_SIZE, p4);
|
||||
return canVillageGoDeeper(boundingBox) && StructureComponent.findIntersecting(pieces, boundingBox) == null
|
||||
? new VillageComponentJamHouse(boundingBox, p4)
|
||||
: null;
|
||||
}
|
||||
|
||||
public static boolean generateCrate(World world, StructureBoundingBox box, int x, int y, int z, ResourceLocation loot) {
|
||||
BlockPos pos = new BlockPos(x, y, z);
|
||||
|
||||
if (box.isVecInside(pos)) {
|
||||
world.setBlockState(pos, ActuallyBlocks.blockGiantChest.getDefaultState(), 2);
|
||||
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileEntityGiantChest) {
|
||||
((TileEntityGiantChest) tile).lootTable = loot;
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addComponentParts(World world, Random rand, StructureBoundingBox sbb) {
|
||||
if (this.averageGroundLevel < 0) {
|
||||
this.averageGroundLevel = this.getAverageGroundLevel(world, sbb);
|
||||
if (this.averageGroundLevel < 0) {
|
||||
return true;
|
||||
}
|
||||
this.boundingBox.offset(0, this.averageGroundLevel - this.boundingBox.maxY + Y_SIZE - 1, 0);
|
||||
}
|
||||
|
||||
this.fillWithBlocks(world, sbb, 0, 0, 0, X_SIZE - 1, Y_SIZE - 1, Z_SIZE - 1, Blocks.AIR);
|
||||
this.spawnActualHouse(world, rand, sbb);
|
||||
|
||||
for (int i = 0; i < X_SIZE; i++) {
|
||||
for (int j = 0; j < Z_SIZE; j++) {
|
||||
this.clearCurrentPositionBlocksUpwards(world, i, Y_SIZE, j, sbb);
|
||||
this.replaceAirAndLiquidDownwards(world, Blocks.COBBLESTONE.getDefaultState(), i, -1, j, sbb);
|
||||
}
|
||||
}
|
||||
|
||||
this.spawnVillagers(world, sbb, 3, 1, 3, 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void fillWithBlocks(World world, StructureBoundingBox sbb, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, Block block) {
|
||||
this.fillWithBlocks(world, sbb, minX, minY, minZ, maxX, maxY, maxZ, block.getDefaultState(), block.getDefaultState(), false);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void spawnActualHouse(World world, Random rand, StructureBoundingBox sbb) {
|
||||
//Base
|
||||
this.fillWithBlocks(world, sbb, 1, 0, 8, 9, 0, 10, Blocks.GRASS);
|
||||
this.fillWithBlocks(world, sbb, 0, 0, 0, 1, 0, 7, Blocks.COBBLESTONE);
|
||||
this.fillWithBlocks(world, sbb, 2, 0, 0, 4, 0, 1, Blocks.COBBLESTONE);
|
||||
this.fillWithBlocks(world, sbb, 9, 0, 0, 10, 0, 7, Blocks.COBBLESTONE);
|
||||
this.fillWithBlocks(world, sbb, 6, 0, 0, 8, 0, 1, Blocks.COBBLESTONE);
|
||||
this.setBlockState(world, Blocks.STONE_STAIRS.getStateFromMeta(3), 5, 0, 0, sbb);
|
||||
this.fillWithBlocks(world, sbb, 2, 0, 7, 3, 0, 7, Blocks.COBBLESTONE);
|
||||
this.fillWithBlocks(world, sbb, 5, 0, 7, 8, 0, 7, Blocks.COBBLESTONE);
|
||||
this.fillWithBlocks(world, sbb, 10, 0, 8, 10, 0, 11, Blocks.COBBLESTONE);
|
||||
this.fillWithBlocks(world, sbb, 0, 0, 8, 0, 0, 11, Blocks.COBBLESTONE);
|
||||
this.fillWithBlocks(world, sbb, 0, 0, 11, 10, 0, 11, Blocks.COBBLESTONE);
|
||||
this.fillWithBlocks(world, sbb, 2, 0, 2, 8, 0, 6, Blocks.PLANKS.getStateFromMeta(1), Blocks.PLANKS.getStateFromMeta(1), false);
|
||||
this.setBlockState(world, Blocks.PLANKS.getStateFromMeta(1), 5, 0, 1, sbb);
|
||||
this.setBlockState(world, Blocks.PLANKS.getStateFromMeta(1), 4, 0, 7, sbb);
|
||||
|
||||
//Garden FENCE
|
||||
this.fillWithBlocks(world, sbb, 0, 1, 8, 0, 1, 11, Blocks.OAK_FENCE);
|
||||
this.fillWithBlocks(world, sbb, 10, 1, 8, 10, 1, 11, Blocks.OAK_FENCE);
|
||||
this.fillWithBlocks(world, sbb, 1, 1, 11, 9, 1, 11, Blocks.OAK_FENCE);
|
||||
|
||||
//Side Walls
|
||||
for (int i = 0; i < 2; i++) {
|
||||
this.fillWithBlocks(world, sbb, 1 + i * 8, 1, 1, 1 + i * 8, 1, 7, Blocks.COBBLESTONE);
|
||||
this.fillWithBlocks(world, sbb, 1 + i * 8, 1, 1, 1 + i * 8, 4, 1, Blocks.COBBLESTONE);
|
||||
this.fillWithBlocks(world, sbb, 1 + i * 8, 1, 7, 1 + i * 8, 4, 7, Blocks.COBBLESTONE);
|
||||
this.fillWithBlocks(world, sbb, 1 + i * 8, 4, 2, 1 + i * 8, 5, 6, Blocks.COBBLESTONE);
|
||||
this.fillWithBlocks(world, sbb, 1 + i * 8, 3, 2, 1 + i * 8, 3, 6, Blocks.PLANKS);
|
||||
this.setBlockState(world, Blocks.PLANKS.getStateFromMeta(0), 1 + i * 8, 2, 2, sbb);
|
||||
this.setBlockState(world, Blocks.PLANKS.getStateFromMeta(0), 1 + i * 8, 2, 6, sbb);
|
||||
this.fillWithBlocks(world, sbb, 1 + i * 8, 2, 3, 1 + i * 8, 2, 5, Blocks.GLASS_PANE);
|
||||
}
|
||||
|
||||
//Front Wall
|
||||
this.fillWithBlocks(world, sbb, 7, 1, 1, 8, 4, 1, Blocks.COBBLESTONE);
|
||||
this.fillWithBlocks(world, sbb, 2, 1, 1, 3, 4, 1, Blocks.COBBLESTONE);
|
||||
this.fillWithBlocks(world, sbb, 4, 4, 1, 7, 4, 1, Blocks.COBBLESTONE);
|
||||
this.fillWithBlocks(world, sbb, 6, 1, 1, 6, 3, 1, Blocks.PLANKS);
|
||||
this.fillWithBlocks(world, sbb, 4, 1, 1, 4, 3, 1, Blocks.PLANKS);
|
||||
this.fillWithBlocks(world, sbb, 5, 3, 1, 5, 3, 1, Blocks.PLANKS);
|
||||
this.setBlockState(world, Blocks.SPRUCE_DOOR.getDefaultState(), 5, 1, 1, sbb);
|
||||
this.setBlockState(world, Blocks.SPRUCE_DOOR.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER), 5, 2, 1, sbb);
|
||||
|
||||
//Back Wall
|
||||
this.fillWithBlocks(world, sbb, 2, 1, 7, 2, 4, 7, Blocks.COBBLESTONE);
|
||||
this.fillWithBlocks(world, sbb, 3, 1, 7, 3, 3, 7, Blocks.PLANKS);
|
||||
this.fillWithBlocks(world, sbb, 4, 3, 7, 8, 3, 7, Blocks.PLANKS);
|
||||
this.fillWithBlocks(world, sbb, 3, 4, 7, 8, 4, 7, Blocks.COBBLESTONE);
|
||||
this.fillWithBlocks(world, sbb, 5, 1, 7, 5, 2, 7, Blocks.PLANKS);
|
||||
this.fillWithBlocks(world, sbb, 6, 1, 7, 8, 1, 7, Blocks.COBBLESTONE);
|
||||
this.fillWithBlocks(world, sbb, 6, 2, 7, 7, 2, 7, Blocks.GLASS_PANE);
|
||||
this.setBlockState(world, Blocks.PLANKS.getStateFromMeta(0), 8, 2, 7, sbb);
|
||||
this.setBlockState(world, Blocks.SPRUCE_DOOR.getDefaultState().withProperty(BlockDoor.FACING, Direction.SOUTH), 4, 1, 7, sbb);
|
||||
this.setBlockState(world, Blocks.SPRUCE_DOOR.getDefaultState().withProperty(BlockDoor.FACING, Direction.SOUTH).withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER), 4, 2, 7, sbb);
|
||||
|
||||
//FENCE Supports
|
||||
this.fillWithBlocks(world, sbb, 0, 1, 8, 0, 3, 8, Blocks.OAK_FENCE);
|
||||
this.fillWithBlocks(world, sbb, 10, 1, 8, 10, 3, 8, Blocks.OAK_FENCE);
|
||||
this.fillWithBlocks(world, sbb, 0, 1, 0, 0, 3, 0, Blocks.OAK_FENCE);
|
||||
this.fillWithBlocks(world, sbb, 10, 1, 0, 10, 3, 0, Blocks.OAK_FENCE);
|
||||
|
||||
//Roof
|
||||
this.fillWithBlocks(world, sbb, 1, 6, 3, 9, 6, 5, Blocks.PLANKS);
|
||||
BlockState stairSouth = Blocks.OAK_STAIRS.getDefaultState().withProperty(BlockStairs.FACING, Direction.SOUTH);
|
||||
BlockState stairNorth = Blocks.OAK_STAIRS.getDefaultState().withProperty(BlockStairs.FACING, Direction.NORTH);
|
||||
this.fillWithBlocks(world, sbb, 0, 4, 0, 10, 4, 0, stairNorth, stairNorth, false);
|
||||
this.fillWithBlocks(world, sbb, 0, 5, 1, 10, 5, 1, stairNorth, stairNorth, false);
|
||||
this.fillWithBlocks(world, sbb, 0, 6, 2, 10, 6, 2, stairNorth, stairNorth, false);
|
||||
this.fillWithBlocks(world, sbb, 0, 4, 8, 10, 4, 8, stairSouth, stairSouth, false);
|
||||
this.fillWithBlocks(world, sbb, 0, 5, 7, 10, 5, 7, stairSouth, stairSouth, false);
|
||||
this.fillWithBlocks(world, sbb, 0, 6, 6, 10, 6, 6, stairSouth, stairSouth, false);
|
||||
this.fillWithBlocks(world, sbb, 0, 7, 3, 10, 7, 5, Blocks.WOODEN_SLAB);
|
||||
|
||||
//Roof Gadgets
|
||||
this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 0, 4, 1, sbb);
|
||||
this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 0, 5, 2, sbb);
|
||||
this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 10, 4, 1, sbb);
|
||||
this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 10, 5, 2, sbb);
|
||||
this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 0, 4, 7, sbb);
|
||||
this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 0, 5, 6, sbb);
|
||||
this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 10, 4, 7, sbb);
|
||||
this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 10, 5, 6, sbb);
|
||||
this.fillWithBlocks(world, sbb, 0, 6, 3, 0, 6, 5, Blocks.PLANKS);
|
||||
this.fillWithBlocks(world, sbb, 10, 6, 3, 10, 6, 5, Blocks.PLANKS);
|
||||
|
||||
//Counter
|
||||
this.fillWithBlocks(world, sbb, 6, 3, 2, 6, 3, 4, Blocks.WOODEN_SLAB.getStateFromMeta(8), Blocks.WOODEN_SLAB.getStateFromMeta(8), false);
|
||||
this.fillWithBlocks(world, sbb, 5, 3, 4, 5, 3, 6, Blocks.WOODEN_SLAB.getStateFromMeta(8), Blocks.WOODEN_SLAB.getStateFromMeta(8), false);
|
||||
this.fillWithBlocks(world, sbb, 6, 1, 2, 6, 1, 4, Blocks.PLANKS);
|
||||
this.fillWithBlocks(world, sbb, 5, 1, 4, 5, 1, 5, Blocks.PLANKS);
|
||||
this.fillWithBlocks(world, sbb, 6, 4, 2, 6, 5, 2, Blocks.OAK_FENCE);
|
||||
this.fillWithBlocks(world, sbb, 5, 4, 4, 5, 5, 4, Blocks.OAK_FENCE);
|
||||
this.fillWithBlocks(world, sbb, 5, 4, 6, 5, 5, 6, Blocks.OAK_FENCE);
|
||||
|
||||
//Decoration
|
||||
this.setBlockState(world, Blocks.OAK_FENCE.getDefaultState(), 2, 1, 2, sbb);
|
||||
this.setBlockState(world, Blocks.LEAVES.getDefaultState().withProperty(BlockLeaves.DECAYABLE, false), 2, 2, 2, sbb);
|
||||
this.setBlockState(world, Blocks.OAK_FENCE.getDefaultState(), 8, 1, 2, sbb);
|
||||
this.setBlockState(world, Blocks.LEAVES.getDefaultState().withProperty(BlockLeaves.DECAYABLE, false), 8, 2, 2, sbb);
|
||||
this.setBlockState(world, Blocks.OAK_FENCE.getDefaultState(), 2, 1, 6, sbb);
|
||||
this.setBlockState(world, Blocks.LEAVES.getDefaultState().withProperty(BlockLeaves.DECAYABLE, false), 2, 2, 6, sbb);
|
||||
BlockState stairWest = Blocks.OAK_STAIRS.getDefaultState().withProperty(BlockStairs.FACING, Direction.WEST);
|
||||
this.fillWithBlocks(world, sbb, 2, 1, 3, 2, 1, 5, stairWest, stairWest, false);
|
||||
this.fillWithBlocks(world, sbb, 3, 1, 2, 5, 1, 3, Blocks.CARPET.getStateFromMeta(10), Blocks.CARPET.getStateFromMeta(10), false);
|
||||
this.fillWithBlocks(world, sbb, 3, 1, 4, 4, 1, 6, Blocks.CARPET.getStateFromMeta(10), Blocks.CARPET.getStateFromMeta(10), false);
|
||||
|
||||
//Loot Chest
|
||||
if (ConfigBoolValues.DUNGEON_LOOT.isEnabled()) {
|
||||
generateCrate(world, this.boundingBox, this.getXWithOffset(8, 6), this.getYWithOffset(1), this.getZWithOffset(8, 6), DungeonLoot.JAM_HOUSE);
|
||||
}
|
||||
|
||||
//Torches
|
||||
this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, Direction.SOUTH), 6, 2, 0, sbb);
|
||||
this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, Direction.SOUTH), 4, 2, 0, sbb);
|
||||
this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, Direction.NORTH), 5, 2, 8, sbb);
|
||||
this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, Direction.NORTH), 3, 2, 8, sbb);
|
||||
this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, Direction.EAST), 2, 3, 2, sbb);
|
||||
this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, Direction.EAST), 2, 3, 6, sbb);
|
||||
this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, Direction.WEST), 8, 3, 2, sbb);
|
||||
this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, Direction.WEST), 8, 3, 6, sbb);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected VillagerProfession chooseForgeProfession(int count, VillagerProfession prof) {
|
||||
return InitVillager.jamProfession;
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * This file ("VillageComponentJamHouse.java") is part of the Actually Additions mod for Minecraft.
|
||||
// * It is created and owned by Ellpeck and distributed
|
||||
// * under the Actually Additions License to be found at
|
||||
// * http://ellpeck.de/actaddlicense
|
||||
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
// *
|
||||
// * © 2015-2017 Ellpeck
|
||||
// */
|
||||
//
|
||||
//package de.ellpeck.actuallyadditions.mod.gen.village.component;
|
||||
//
|
||||
//import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||
//import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||
//import de.ellpeck.actuallyadditions.mod.gen.village.InitVillager;
|
||||
//import de.ellpeck.actuallyadditions.mod.misc.DungeonLoot;
|
||||
//import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChest;
|
||||
//import net.minecraft.block.Block;
|
||||
//import net.minecraft.block.BlockState;
|
||||
//import net.minecraft.block.Blocks;
|
||||
//import net.minecraft.tileentity.TileEntity;
|
||||
//import net.minecraft.util.Direction;
|
||||
//import net.minecraft.util.ResourceLocation;
|
||||
//import net.minecraft.util.math.BlockPos;
|
||||
//import net.minecraft.world.World;
|
||||
//import net.minecraft.world.gen.structure.StructureBoundingBox;
|
||||
//import net.minecraft.world.gen.structure.StructureComponent;
|
||||
//import net.minecraft.world.gen.structure.StructureVillagePieces;
|
||||
//import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession;
|
||||
//
|
||||
//import java.util.List;
|
||||
//import java.util.Random;
|
||||
//
|
||||
//public class VillageComponentJamHouse extends StructureVillagePieces.House1 {
|
||||
//
|
||||
// private static final int X_SIZE = 11;
|
||||
// private static final int Y_SIZE = 8;
|
||||
// private static final int Z_SIZE = 12;
|
||||
//
|
||||
// private int averageGroundLevel = -1;
|
||||
//
|
||||
// public VillageComponentJamHouse() {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public VillageComponentJamHouse(StructureBoundingBox boundingBox, Direction par5) {
|
||||
// this.setCoordBaseMode(par5);
|
||||
// this.boundingBox = boundingBox;
|
||||
// }
|
||||
//
|
||||
// public static VillageComponentJamHouse buildComponent(List<StructureComponent> pieces, int p1, int p2, int p3, Direction p4) {
|
||||
// StructureBoundingBox boundingBox = StructureBoundingBox.getComponentToAddBoundingBox(p1, p2, p3, 0, 0, 0, X_SIZE, Y_SIZE, Z_SIZE, p4);
|
||||
// return canVillageGoDeeper(boundingBox) && StructureComponent.findIntersecting(pieces, boundingBox) == null
|
||||
// ? new VillageComponentJamHouse(boundingBox, p4)
|
||||
// : null;
|
||||
// }
|
||||
//
|
||||
// public static boolean generateCrate(World world, StructureBoundingBox box, int x, int y, int z, ResourceLocation loot) {
|
||||
// BlockPos pos = new BlockPos(x, y, z);
|
||||
//
|
||||
// if (box.isVecInside(pos)) {
|
||||
// world.setBlockState(pos, ActuallyBlocks.blockGiantChest.getDefaultState(), 2);
|
||||
//
|
||||
// TileEntity tile = world.getTileEntity(pos);
|
||||
// if (tile instanceof TileEntityGiantChest) {
|
||||
// ((TileEntityGiantChest) tile).lootTable = loot;
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
// } else {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean addComponentParts(World world, Random rand, StructureBoundingBox sbb) {
|
||||
// if (this.averageGroundLevel < 0) {
|
||||
// this.averageGroundLevel = this.getAverageGroundLevel(world, sbb);
|
||||
// if (this.averageGroundLevel < 0) {
|
||||
// return true;
|
||||
// }
|
||||
// this.boundingBox.offset(0, this.averageGroundLevel - this.boundingBox.maxY + Y_SIZE - 1, 0);
|
||||
// }
|
||||
//
|
||||
// this.fillWithBlocks(world, sbb, 0, 0, 0, X_SIZE - 1, Y_SIZE - 1, Z_SIZE - 1, Blocks.AIR);
|
||||
// this.spawnActualHouse(world, rand, sbb);
|
||||
//
|
||||
// for (int i = 0; i < X_SIZE; i++) {
|
||||
// for (int j = 0; j < Z_SIZE; j++) {
|
||||
// this.clearCurrentPositionBlocksUpwards(world, i, Y_SIZE, j, sbb);
|
||||
// this.replaceAirAndLiquidDownwards(world, Blocks.COBBLESTONE.getDefaultState(), i, -1, j, sbb);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// this.spawnVillagers(world, sbb, 3, 1, 3, 1);
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// public void fillWithBlocks(World world, StructureBoundingBox sbb, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, Block block) {
|
||||
// this.fillWithBlocks(world, sbb, minX, minY, minZ, maxX, maxY, maxZ, block.getDefaultState(), block.getDefaultState(), false);
|
||||
// }
|
||||
//
|
||||
// @SuppressWarnings("deprecation")
|
||||
// public void spawnActualHouse(World world, Random rand, StructureBoundingBox sbb) {
|
||||
// //Base
|
||||
// this.fillWithBlocks(world, sbb, 1, 0, 8, 9, 0, 10, Blocks.GRASS);
|
||||
// this.fillWithBlocks(world, sbb, 0, 0, 0, 1, 0, 7, Blocks.COBBLESTONE);
|
||||
// this.fillWithBlocks(world, sbb, 2, 0, 0, 4, 0, 1, Blocks.COBBLESTONE);
|
||||
// this.fillWithBlocks(world, sbb, 9, 0, 0, 10, 0, 7, Blocks.COBBLESTONE);
|
||||
// this.fillWithBlocks(world, sbb, 6, 0, 0, 8, 0, 1, Blocks.COBBLESTONE);
|
||||
// this.setBlockState(world, Blocks.STONE_STAIRS.getStateFromMeta(3), 5, 0, 0, sbb);
|
||||
// this.fillWithBlocks(world, sbb, 2, 0, 7, 3, 0, 7, Blocks.COBBLESTONE);
|
||||
// this.fillWithBlocks(world, sbb, 5, 0, 7, 8, 0, 7, Blocks.COBBLESTONE);
|
||||
// this.fillWithBlocks(world, sbb, 10, 0, 8, 10, 0, 11, Blocks.COBBLESTONE);
|
||||
// this.fillWithBlocks(world, sbb, 0, 0, 8, 0, 0, 11, Blocks.COBBLESTONE);
|
||||
// this.fillWithBlocks(world, sbb, 0, 0, 11, 10, 0, 11, Blocks.COBBLESTONE);
|
||||
// this.fillWithBlocks(world, sbb, 2, 0, 2, 8, 0, 6, Blocks.PLANKS.getStateFromMeta(1), Blocks.PLANKS.getStateFromMeta(1), false);
|
||||
// this.setBlockState(world, Blocks.PLANKS.getStateFromMeta(1), 5, 0, 1, sbb);
|
||||
// this.setBlockState(world, Blocks.PLANKS.getStateFromMeta(1), 4, 0, 7, sbb);
|
||||
//
|
||||
// //Garden FENCE
|
||||
// this.fillWithBlocks(world, sbb, 0, 1, 8, 0, 1, 11, Blocks.OAK_FENCE);
|
||||
// this.fillWithBlocks(world, sbb, 10, 1, 8, 10, 1, 11, Blocks.OAK_FENCE);
|
||||
// this.fillWithBlocks(world, sbb, 1, 1, 11, 9, 1, 11, Blocks.OAK_FENCE);
|
||||
//
|
||||
// //Side Walls
|
||||
// for (int i = 0; i < 2; i++) {
|
||||
// this.fillWithBlocks(world, sbb, 1 + i * 8, 1, 1, 1 + i * 8, 1, 7, Blocks.COBBLESTONE);
|
||||
// this.fillWithBlocks(world, sbb, 1 + i * 8, 1, 1, 1 + i * 8, 4, 1, Blocks.COBBLESTONE);
|
||||
// this.fillWithBlocks(world, sbb, 1 + i * 8, 1, 7, 1 + i * 8, 4, 7, Blocks.COBBLESTONE);
|
||||
// this.fillWithBlocks(world, sbb, 1 + i * 8, 4, 2, 1 + i * 8, 5, 6, Blocks.COBBLESTONE);
|
||||
// this.fillWithBlocks(world, sbb, 1 + i * 8, 3, 2, 1 + i * 8, 3, 6, Blocks.PLANKS);
|
||||
// this.setBlockState(world, Blocks.PLANKS.getStateFromMeta(0), 1 + i * 8, 2, 2, sbb);
|
||||
// this.setBlockState(world, Blocks.PLANKS.getStateFromMeta(0), 1 + i * 8, 2, 6, sbb);
|
||||
// this.fillWithBlocks(world, sbb, 1 + i * 8, 2, 3, 1 + i * 8, 2, 5, Blocks.GLASS_PANE);
|
||||
// }
|
||||
//
|
||||
// //Front Wall
|
||||
// this.fillWithBlocks(world, sbb, 7, 1, 1, 8, 4, 1, Blocks.COBBLESTONE);
|
||||
// this.fillWithBlocks(world, sbb, 2, 1, 1, 3, 4, 1, Blocks.COBBLESTONE);
|
||||
// this.fillWithBlocks(world, sbb, 4, 4, 1, 7, 4, 1, Blocks.COBBLESTONE);
|
||||
// this.fillWithBlocks(world, sbb, 6, 1, 1, 6, 3, 1, Blocks.PLANKS);
|
||||
// this.fillWithBlocks(world, sbb, 4, 1, 1, 4, 3, 1, Blocks.PLANKS);
|
||||
// this.fillWithBlocks(world, sbb, 5, 3, 1, 5, 3, 1, Blocks.PLANKS);
|
||||
// this.setBlockState(world, Blocks.SPRUCE_DOOR.getDefaultState(), 5, 1, 1, sbb);
|
||||
// this.setBlockState(world, Blocks.SPRUCE_DOOR.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER), 5, 2, 1, sbb);
|
||||
//
|
||||
// //Back Wall
|
||||
// this.fillWithBlocks(world, sbb, 2, 1, 7, 2, 4, 7, Blocks.COBBLESTONE);
|
||||
// this.fillWithBlocks(world, sbb, 3, 1, 7, 3, 3, 7, Blocks.PLANKS);
|
||||
// this.fillWithBlocks(world, sbb, 4, 3, 7, 8, 3, 7, Blocks.PLANKS);
|
||||
// this.fillWithBlocks(world, sbb, 3, 4, 7, 8, 4, 7, Blocks.COBBLESTONE);
|
||||
// this.fillWithBlocks(world, sbb, 5, 1, 7, 5, 2, 7, Blocks.PLANKS);
|
||||
// this.fillWithBlocks(world, sbb, 6, 1, 7, 8, 1, 7, Blocks.COBBLESTONE);
|
||||
// this.fillWithBlocks(world, sbb, 6, 2, 7, 7, 2, 7, Blocks.GLASS_PANE);
|
||||
// this.setBlockState(world, Blocks.PLANKS.getStateFromMeta(0), 8, 2, 7, sbb);
|
||||
// this.setBlockState(world, Blocks.SPRUCE_DOOR.getDefaultState().withProperty(BlockDoor.FACING, Direction.SOUTH), 4, 1, 7, sbb);
|
||||
// this.setBlockState(world, Blocks.SPRUCE_DOOR.getDefaultState().withProperty(BlockDoor.FACING, Direction.SOUTH).withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER), 4, 2, 7, sbb);
|
||||
//
|
||||
// //FENCE Supports
|
||||
// this.fillWithBlocks(world, sbb, 0, 1, 8, 0, 3, 8, Blocks.OAK_FENCE);
|
||||
// this.fillWithBlocks(world, sbb, 10, 1, 8, 10, 3, 8, Blocks.OAK_FENCE);
|
||||
// this.fillWithBlocks(world, sbb, 0, 1, 0, 0, 3, 0, Blocks.OAK_FENCE);
|
||||
// this.fillWithBlocks(world, sbb, 10, 1, 0, 10, 3, 0, Blocks.OAK_FENCE);
|
||||
//
|
||||
// //Roof
|
||||
// this.fillWithBlocks(world, sbb, 1, 6, 3, 9, 6, 5, Blocks.PLANKS);
|
||||
// BlockState stairSouth = Blocks.OAK_STAIRS.getDefaultState().withProperty(BlockStairs.FACING, Direction.SOUTH);
|
||||
// BlockState stairNorth = Blocks.OAK_STAIRS.getDefaultState().withProperty(BlockStairs.FACING, Direction.NORTH);
|
||||
// this.fillWithBlocks(world, sbb, 0, 4, 0, 10, 4, 0, stairNorth, stairNorth, false);
|
||||
// this.fillWithBlocks(world, sbb, 0, 5, 1, 10, 5, 1, stairNorth, stairNorth, false);
|
||||
// this.fillWithBlocks(world, sbb, 0, 6, 2, 10, 6, 2, stairNorth, stairNorth, false);
|
||||
// this.fillWithBlocks(world, sbb, 0, 4, 8, 10, 4, 8, stairSouth, stairSouth, false);
|
||||
// this.fillWithBlocks(world, sbb, 0, 5, 7, 10, 5, 7, stairSouth, stairSouth, false);
|
||||
// this.fillWithBlocks(world, sbb, 0, 6, 6, 10, 6, 6, stairSouth, stairSouth, false);
|
||||
// this.fillWithBlocks(world, sbb, 0, 7, 3, 10, 7, 5, Blocks.WOODEN_SLAB);
|
||||
//
|
||||
// //Roof Gadgets
|
||||
// this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 0, 4, 1, sbb);
|
||||
// this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 0, 5, 2, sbb);
|
||||
// this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 10, 4, 1, sbb);
|
||||
// this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 10, 5, 2, sbb);
|
||||
// this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 0, 4, 7, sbb);
|
||||
// this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 0, 5, 6, sbb);
|
||||
// this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 10, 4, 7, sbb);
|
||||
// this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 10, 5, 6, sbb);
|
||||
// this.fillWithBlocks(world, sbb, 0, 6, 3, 0, 6, 5, Blocks.PLANKS);
|
||||
// this.fillWithBlocks(world, sbb, 10, 6, 3, 10, 6, 5, Blocks.PLANKS);
|
||||
//
|
||||
// //Counter
|
||||
// this.fillWithBlocks(world, sbb, 6, 3, 2, 6, 3, 4, Blocks.WOODEN_SLAB.getStateFromMeta(8), Blocks.WOODEN_SLAB.getStateFromMeta(8), false);
|
||||
// this.fillWithBlocks(world, sbb, 5, 3, 4, 5, 3, 6, Blocks.WOODEN_SLAB.getStateFromMeta(8), Blocks.WOODEN_SLAB.getStateFromMeta(8), false);
|
||||
// this.fillWithBlocks(world, sbb, 6, 1, 2, 6, 1, 4, Blocks.PLANKS);
|
||||
// this.fillWithBlocks(world, sbb, 5, 1, 4, 5, 1, 5, Blocks.PLANKS);
|
||||
// this.fillWithBlocks(world, sbb, 6, 4, 2, 6, 5, 2, Blocks.OAK_FENCE);
|
||||
// this.fillWithBlocks(world, sbb, 5, 4, 4, 5, 5, 4, Blocks.OAK_FENCE);
|
||||
// this.fillWithBlocks(world, sbb, 5, 4, 6, 5, 5, 6, Blocks.OAK_FENCE);
|
||||
//
|
||||
// //Decoration
|
||||
// this.setBlockState(world, Blocks.OAK_FENCE.getDefaultState(), 2, 1, 2, sbb);
|
||||
// this.setBlockState(world, Blocks.LEAVES.getDefaultState().withProperty(BlockLeaves.DECAYABLE, false), 2, 2, 2, sbb);
|
||||
// this.setBlockState(world, Blocks.OAK_FENCE.getDefaultState(), 8, 1, 2, sbb);
|
||||
// this.setBlockState(world, Blocks.LEAVES.getDefaultState().withProperty(BlockLeaves.DECAYABLE, false), 8, 2, 2, sbb);
|
||||
// this.setBlockState(world, Blocks.OAK_FENCE.getDefaultState(), 2, 1, 6, sbb);
|
||||
// this.setBlockState(world, Blocks.LEAVES.getDefaultState().withProperty(BlockLeaves.DECAYABLE, false), 2, 2, 6, sbb);
|
||||
// BlockState stairWest = Blocks.OAK_STAIRS.getDefaultState().withProperty(BlockStairs.FACING, Direction.WEST);
|
||||
// this.fillWithBlocks(world, sbb, 2, 1, 3, 2, 1, 5, stairWest, stairWest, false);
|
||||
// this.fillWithBlocks(world, sbb, 3, 1, 2, 5, 1, 3, Blocks.CARPET.getStateFromMeta(10), Blocks.CARPET.getStateFromMeta(10), false);
|
||||
// this.fillWithBlocks(world, sbb, 3, 1, 4, 4, 1, 6, Blocks.CARPET.getStateFromMeta(10), Blocks.CARPET.getStateFromMeta(10), false);
|
||||
//
|
||||
// //Loot Chest
|
||||
// if (ConfigBoolValues.DUNGEON_LOOT.isEnabled()) {
|
||||
// generateCrate(world, this.boundingBox, this.getXWithOffset(8, 6), this.getYWithOffset(1), this.getZWithOffset(8, 6), DungeonLoot.JAM_HOUSE);
|
||||
// }
|
||||
//
|
||||
// //Torches
|
||||
// this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, Direction.SOUTH), 6, 2, 0, sbb);
|
||||
// this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, Direction.SOUTH), 4, 2, 0, sbb);
|
||||
// this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, Direction.NORTH), 5, 2, 8, sbb);
|
||||
// this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, Direction.NORTH), 3, 2, 8, sbb);
|
||||
// this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, Direction.EAST), 2, 3, 2, sbb);
|
||||
// this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, Direction.EAST), 2, 3, 6, sbb);
|
||||
// this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, Direction.WEST), 8, 3, 2, sbb);
|
||||
// this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, Direction.WEST), 8, 3, 6, sbb);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected VillagerProfession chooseForgeProfession(int count, VillagerProfession prof) {
|
||||
// return InitVillager.jamProfession;
|
||||
// }
|
||||
//}
|
||||
|
|
|
@ -1,38 +1,38 @@
|
|||
/*
|
||||
* This file ("VillageCustomCropFieldHandler.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2017 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.gen.village.component.handler;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.gen.village.component.VillageComponentCustomCropField;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.world.gen.structure.StructureComponent;
|
||||
import net.minecraft.world.gen.structure.StructureVillagePieces;
|
||||
import net.minecraftforge.fml.common.registry.VillagerRegistry;
|
||||
|
||||
public class VillageCustomCropFieldHandler implements VillagerRegistry.IVillageCreationHandler {
|
||||
|
||||
@Override
|
||||
public StructureVillagePieces.PieceWeight getVillagePieceWeight(Random random, int i) {
|
||||
return new StructureVillagePieces.PieceWeight(VillageComponentCustomCropField.class, 5, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getComponentClass() {
|
||||
return VillageComponentCustomCropField.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructureVillagePieces.Village buildComponent(StructureVillagePieces.PieceWeight villagePiece, StructureVillagePieces.Start startPiece, List<StructureComponent> pieces, Random random, int p1, int p2, int p3, Direction facing, int p5) {
|
||||
return VillageComponentCustomCropField.buildComponent(pieces, p1, p2, p3, facing);
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * This file ("VillageCustomCropFieldHandler.java") is part of the Actually Additions mod for Minecraft.
|
||||
// * It is created and owned by Ellpeck and distributed
|
||||
// * under the Actually Additions License to be found at
|
||||
// * http://ellpeck.de/actaddlicense
|
||||
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
// *
|
||||
// * © 2015-2017 Ellpeck
|
||||
// */
|
||||
//
|
||||
//package de.ellpeck.actuallyadditions.mod.gen.village.component.handler;
|
||||
//
|
||||
//import java.util.List;
|
||||
//import java.util.Random;
|
||||
//
|
||||
//import de.ellpeck.actuallyadditions.mod.gen.village.component.VillageComponentCustomCropField;
|
||||
//import net.minecraft.util.Direction;
|
||||
//import net.minecraft.world.gen.structure.StructureComponent;
|
||||
//import net.minecraft.world.gen.structure.StructureVillagePieces;
|
||||
//import net.minecraftforge.fml.common.registry.VillagerRegistry;
|
||||
//
|
||||
//public class VillageCustomCropFieldHandler implements VillagerRegistry.IVillageCreationHandler {
|
||||
//
|
||||
// @Override
|
||||
// public StructureVillagePieces.PieceWeight getVillagePieceWeight(Random random, int i) {
|
||||
// return new StructureVillagePieces.PieceWeight(VillageComponentCustomCropField.class, 5, 1);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Class<?> getComponentClass() {
|
||||
// return VillageComponentCustomCropField.class;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public StructureVillagePieces.Village buildComponent(StructureVillagePieces.PieceWeight villagePiece, StructureVillagePieces.Start startPiece, List<StructureComponent> pieces, Random random, int p1, int p2, int p3, Direction facing, int p5) {
|
||||
// return VillageComponentCustomCropField.buildComponent(pieces, p1, p2, p3, facing);
|
||||
// }
|
||||
//}
|
||||
|
|
|
@ -1,38 +1,38 @@
|
|||
/*
|
||||
* This file ("VillageEngineerHouseHandler.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2017 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.gen.village.component.handler;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.gen.village.component.VillageComponentEngineerHouse;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.world.gen.structure.StructureComponent;
|
||||
import net.minecraft.world.gen.structure.StructureVillagePieces;
|
||||
import net.minecraftforge.fml.common.registry.VillagerRegistry;
|
||||
|
||||
public class VillageEngineerHouseHandler implements VillagerRegistry.IVillageCreationHandler {
|
||||
|
||||
@Override
|
||||
public StructureVillagePieces.PieceWeight getVillagePieceWeight(Random random, int i) {
|
||||
return new StructureVillagePieces.PieceWeight(VillageComponentEngineerHouse.class, 10, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getComponentClass() {
|
||||
return VillageComponentEngineerHouse.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructureVillagePieces.Village buildComponent(StructureVillagePieces.PieceWeight villagePiece, StructureVillagePieces.Start startPiece, List<StructureComponent> pieces, Random random, int p1, int p2, int p3, Direction facing, int p5) {
|
||||
return VillageComponentEngineerHouse.buildComponent(pieces, p1, p2, p3, facing);
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * This file ("VillageEngineerHouseHandler.java") is part of the Actually Additions mod for Minecraft.
|
||||
// * It is created and owned by Ellpeck and distributed
|
||||
// * under the Actually Additions License to be found at
|
||||
// * http://ellpeck.de/actaddlicense
|
||||
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
// *
|
||||
// * © 2015-2017 Ellpeck
|
||||
// */
|
||||
//
|
||||
//package de.ellpeck.actuallyadditions.mod.gen.village.component.handler;
|
||||
//
|
||||
//import java.util.List;
|
||||
//import java.util.Random;
|
||||
//
|
||||
//import de.ellpeck.actuallyadditions.mod.gen.village.component.VillageComponentEngineerHouse;
|
||||
//import net.minecraft.util.Direction;
|
||||
//import net.minecraft.world.gen.structure.StructureComponent;
|
||||
//import net.minecraft.world.gen.structure.StructureVillagePieces;
|
||||
//import net.minecraftforge.fml.common.registry.VillagerRegistry;
|
||||
//
|
||||
//public class VillageEngineerHouseHandler implements VillagerRegistry.IVillageCreationHandler {
|
||||
//
|
||||
// @Override
|
||||
// public StructureVillagePieces.PieceWeight getVillagePieceWeight(Random random, int i) {
|
||||
// return new StructureVillagePieces.PieceWeight(VillageComponentEngineerHouse.class, 10, 1);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Class<?> getComponentClass() {
|
||||
// return VillageComponentEngineerHouse.class;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public StructureVillagePieces.Village buildComponent(StructureVillagePieces.PieceWeight villagePiece, StructureVillagePieces.Start startPiece, List<StructureComponent> pieces, Random random, int p1, int p2, int p3, Direction facing, int p5) {
|
||||
// return VillageComponentEngineerHouse.buildComponent(pieces, p1, p2, p3, facing);
|
||||
// }
|
||||
//}
|
||||
|
|
|
@ -1,38 +1,38 @@
|
|||
/*
|
||||
* This file ("VillageJamHouseHandler.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2017 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.gen.village.component.handler;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.gen.village.component.VillageComponentJamHouse;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.world.gen.structure.StructureComponent;
|
||||
import net.minecraft.world.gen.structure.StructureVillagePieces;
|
||||
import net.minecraftforge.fml.common.registry.VillagerRegistry;
|
||||
|
||||
public class VillageJamHouseHandler implements VillagerRegistry.IVillageCreationHandler {
|
||||
|
||||
@Override
|
||||
public StructureVillagePieces.PieceWeight getVillagePieceWeight(Random random, int i) {
|
||||
return new StructureVillagePieces.PieceWeight(VillageComponentJamHouse.class, 3, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getComponentClass() {
|
||||
return VillageComponentJamHouse.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructureVillagePieces.Village buildComponent(StructureVillagePieces.PieceWeight villagePiece, StructureVillagePieces.Start startPiece, List<StructureComponent> pieces, Random random, int p1, int p2, int p3, Direction facing, int p5) {
|
||||
return VillageComponentJamHouse.buildComponent(pieces, p1, p2, p3, facing);
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * This file ("VillageJamHouseHandler.java") is part of the Actually Additions mod for Minecraft.
|
||||
// * It is created and owned by Ellpeck and distributed
|
||||
// * under the Actually Additions License to be found at
|
||||
// * http://ellpeck.de/actaddlicense
|
||||
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
// *
|
||||
// * © 2015-2017 Ellpeck
|
||||
// */
|
||||
//
|
||||
//package de.ellpeck.actuallyadditions.mod.gen.village.component.handler;
|
||||
//
|
||||
//import java.util.List;
|
||||
//import java.util.Random;
|
||||
//
|
||||
//import de.ellpeck.actuallyadditions.mod.gen.village.component.VillageComponentJamHouse;
|
||||
//import net.minecraft.util.Direction;
|
||||
//import net.minecraft.world.gen.structure.StructureComponent;
|
||||
//import net.minecraft.world.gen.structure.StructureVillagePieces;
|
||||
//import net.minecraftforge.fml.common.registry.VillagerRegistry;
|
||||
//
|
||||
//public class VillageJamHouseHandler implements VillagerRegistry.IVillageCreationHandler {
|
||||
//
|
||||
// @Override
|
||||
// public StructureVillagePieces.PieceWeight getVillagePieceWeight(Random random, int i) {
|
||||
// return new StructureVillagePieces.PieceWeight(VillageComponentJamHouse.class, 3, 1);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Class<?> getComponentClass() {
|
||||
// return VillageComponentJamHouse.class;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public StructureVillagePieces.Village buildComponent(StructureVillagePieces.PieceWeight villagePiece, StructureVillagePieces.Start startPiece, List<StructureComponent> pieces, Random random, int p1, int p2, int p3, Direction facing, int p5) {
|
||||
// return VillageComponentJamHouse.buildComponent(pieces, p1, p2, p3, facing);
|
||||
// }
|
||||
//}
|
||||
|
|
|
@ -16,10 +16,12 @@ import de.ellpeck.actuallyadditions.mod.tile.TileEntityFurnaceDouble;
|
|||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.IRecipeType;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import java.util.Objects;
|
||||
|
@ -73,8 +75,16 @@ public class ContainerFurnaceDouble extends Container {
|
|||
}
|
||||
//Other Slots in Inventory excluded
|
||||
else if (slot >= inventoryStart) {
|
||||
// TODO: VALIDATE
|
||||
IRecipe<?> irecipe = this.furnace.getWorld().getRecipeManager().getRecipe(IRecipeType.SMELTING, new Inventory(newStack), this.furnace.getWorld()).orElse(null);
|
||||
if (irecipe == null) {
|
||||
return StackUtil.getEmpty();
|
||||
}
|
||||
|
||||
ItemStack recipeOutput = irecipe.getRecipeOutput();
|
||||
|
||||
//Shift from Inventory
|
||||
if (StackUtil.isValid(FurnaceRecipes.instance().getSmeltingResult(newStack))) {
|
||||
if (StackUtil.isValid(recipeOutput)) {
|
||||
if (!this.mergeItemStack(newStack, TileEntityFurnaceDouble.SLOT_INPUT_1, TileEntityFurnaceDouble.SLOT_INPUT_1 + 1, false)) {
|
||||
if (!this.mergeItemStack(newStack, TileEntityFurnaceDouble.SLOT_INPUT_2, TileEntityFurnaceDouble.SLOT_INPUT_2 + 1, false)) {
|
||||
return StackUtil.getEmpty();
|
||||
|
|
|
@ -10,24 +10,24 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.inventory.gui;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.ContainerFireworkBox;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityFireworkBox;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.client.gui.widget.AbstractSlider;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
|
||||
// TODO: FIX ME
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class GuiFireworkBox extends ContainerScreen<ContainerFireworkBox> implements GuiResponder {
|
||||
public class GuiFireworkBox extends ContainerScreen<ContainerFireworkBox> {
|
||||
|
||||
private final TileEntityFireworkBox tile;
|
||||
// private final TileEntityFireworkBox tile;
|
||||
|
||||
public GuiFireworkBox(TileEntity tile) {
|
||||
super(new ContainerFireworkBox());
|
||||
this.tile = (TileEntityFireworkBox) tile;
|
||||
public GuiFireworkBox(ContainerFireworkBox screenContainer, PlayerInventory inv, ITextComponent titleIn) {
|
||||
super(screenContainer, inv, titleIn);
|
||||
// this.tile = tile.;
|
||||
this.xSize = 300;
|
||||
this.ySize = 120;
|
||||
}
|
||||
|
@ -35,77 +35,98 @@ public class GuiFireworkBox extends ContainerScreen<ContainerFireworkBox> implem
|
|||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
this.addButton(new CustomSlider(this, 0, this.guiLeft, this.guiTop, "Value Play", 0F, 5F, this.tile.intValuePlay, IntFormatter.INSTANCE));
|
||||
this.addButton(new CustomSlider(this, 1, this.guiLeft, this.guiTop + 20, "Average Charge Amount", 1F, 4F, this.tile.chargeAmount, IntFormatter.INSTANCE));
|
||||
this.addButton(new CustomSlider(this, 2, this.guiLeft, this.guiTop + 40, "Average Flight Time", 1F, 3F, this.tile.flightTime, IntFormatter.INSTANCE));
|
||||
this.addButton(new CustomSlider(this, 3, this.guiLeft, this.guiTop + 60, "Effect Chance", 0F, 1F, this.tile.trailOrFlickerChance, null));
|
||||
this.addButton(new CustomSlider(this, 4, this.guiLeft, this.guiTop + 80, "Flicker/Trail Ratio", 0F, 1F, this.tile.flickerChance, null));
|
||||
this.addButton(new CustomSlider(this, 5, this.guiLeft, this.guiTop + 100, "Color Amount", 1, 6, this.tile.colorAmount, IntFormatter.INSTANCE));
|
||||
|
||||
this.addButton(new CustomSlider(this, 6, this.guiLeft + 150, this.guiTop, "Small Ball", 0F, 1F, this.tile.typeChance0, null));
|
||||
this.addButton(new CustomSlider(this, 7, this.guiLeft + 150, this.guiTop + 20, "Large Ball", 0F, 1F, this.tile.typeChance1, null));
|
||||
this.addButton(new CustomSlider(this, 8, this.guiLeft + 150, this.guiTop + 40, "Star Shape", 0F, 1F, this.tile.typeChance2, null));
|
||||
this.addButton(new CustomSlider(this, 9, this.guiLeft + 150, this.guiTop + 60, "Creeper Shape", 0F, 1F, this.tile.typeChance3, null));
|
||||
this.addButton(new CustomSlider(this, 10, this.guiLeft + 150, this.guiTop + 80, "Burst", 0F, 1F, this.tile.typeChance4, null));
|
||||
|
||||
this.addButton(new CustomSlider(this, 11, this.guiLeft + 150, this.guiTop + 100, "Area of Effect", 0, 4, this.tile.areaOfEffect, IntFormatter.INSTANCE));
|
||||
//
|
||||
// this.addButton(new CustomSlider(this.guiLeft, this.guiTop, "Value Play", 0F, 5F, this.tile.intValuePlay, IntFormatter.INSTANCE));
|
||||
// this.addButton(new CustomSlider(this.guiLeft, this.guiTop + 20, "Average Charge Amount", 1F, 4F, this.tile.chargeAmount, IntFormatter.INSTANCE));
|
||||
// this.addButton(new CustomSlider(this.guiLeft, this.guiTop + 40, "Average Flight Time", 1F, 3F, this.tile.flightTime, IntFormatter.INSTANCE));
|
||||
// this.addButton(new CustomSlider(this.guiLeft, this.guiTop + 60, "Effect Chance", 0F, 1F, this.tile.trailOrFlickerChance, null));
|
||||
// this.addButton(new CustomSlider(this.guiLeft, this.guiTop + 80, "Flicker/Trail Ratio", 0F, 1F, this.tile.flickerChance, null));
|
||||
// this.addButton(new CustomSlider(this.guiLeft, this.guiTop + 100, "Color Amount", 1, 6, this.tile.colorAmount, IntFormatter.INSTANCE));
|
||||
//
|
||||
// this.addButton(new CustomSlider(this.guiLeft + 150, this.guiTop, "Small Ball", 0F, 1F, this.tile.typeChance0, null));
|
||||
// this.addButton(new CustomSlider(this.guiLeft + 150, this.guiTop + 20, "Large Ball", 0F, 1F, this.tile.typeChance1, null));
|
||||
// this.addButton(new CustomSlider(this.guiLeft + 150, this.guiTop + 40, "Star Shape", 0F, 1F, this.tile.typeChance2, null));
|
||||
// this.addButton(new CustomSlider(this.guiLeft + 150, this.guiTop + 60, "Creeper Shape", 0F, 1F, this.tile.typeChance3, null));
|
||||
// this.addButton(new CustomSlider(this.guiLeft + 150, this.guiTop + 80, "Burst", 0F, 1F, this.tile.typeChance4, null));
|
||||
//
|
||||
// this.addButton(new CustomSlider(this, 11, this.guiLeft + 150, this.guiTop + 100, "Area of Effect", 0, 4, this.tile.areaOfEffect, IntFormatter.INSTANCE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEntryValue(int id, float value) {
|
||||
Button button = this.buttonList.get(id);
|
||||
if (button instanceof GuiSlider) {
|
||||
if (!((GuiSlider) button).isMouseDown) {
|
||||
System.out.println("SETTING VALUE FOR " + id + "!!");
|
||||
PacketHandlerHelper.sendNumberPacket(this.tile, value, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
|
||||
protected void drawGuiContainerBackgroundLayer(MatrixStack matrixStack, float partialTicks, int x, int y) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawGuiContainerForegroundLayer(int x, int y) {
|
||||
AssetUtil.displayNameString(this.font, this.xSize, -10, this.tile);
|
||||
}
|
||||
// TODO: FIX;
|
||||
// @Override
|
||||
// public void setEntryValue(int id, float value) {
|
||||
// Button button = this.buttonList.get(id);
|
||||
// if (button instanceof GuiSlider) {
|
||||
// if (!((GuiSlider) button).isMouseDown) {
|
||||
// System.out.println("SETTING VALUE FOR " + id + "!!");
|
||||
// PacketHandlerHelper.sendNumberPacket(this.tile, value, id);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void setEntryValue(int id, boolean value) {
|
||||
// @Override
|
||||
// protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void drawGuiContainerForegroundLayer(int x, int y) {
|
||||
// AssetUtil.displayNameString(this.font, this.xSize, -10, this.tile);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void setEntryValue(int id, boolean value) {
|
||||
|
||||
}
|
||||
//}
|
||||
|
||||
@Override
|
||||
public void setEntryValue(int id, String value) {
|
||||
// @Override
|
||||
// public void setEntryValue(int id, String value) {
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
private static class CustomSlider extends GuiSlider {
|
||||
|
||||
private final GuiResponder responder;
|
||||
|
||||
public CustomSlider(GuiResponder guiResponder, int idIn, int x, int y, String name, float min, float max, float defaultValue, FormatHelper formatter) {
|
||||
super(guiResponder, idIn, x, y, name, min, max, defaultValue, formatter);
|
||||
this.responder = guiResponder;
|
||||
// TODO: FIX
|
||||
private static class CustomSlider extends AbstractSlider {
|
||||
public CustomSlider(int x, int y, int width, int height, ITextComponent message, double defaultValue) {
|
||||
super(x, y, width, height, message, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
// private final GuiResponder responder;
|
||||
//
|
||||
// public CustomSlider(GuiResponder guiResponder, int idIn, int x, int y, String name, float min, float max, float defaultValue, FormatHelper formatter) {
|
||||
// super(guiResponder, idIn, x, y, name, min, max, defaultValue, formatter);
|
||||
// this.responder = guiResponder;
|
||||
// }
|
||||
|
||||
// @Override
|
||||
public void mouseReleased(int mouseX, int mouseY) {
|
||||
super.mouseReleased(mouseX, mouseY);
|
||||
this.responder.setEntryValue(this.id, this.getSliderValue());
|
||||
// super.mouseReleased(mouseX, mouseY);
|
||||
// this.responder.setEntryValue(this.id, this.getSliderValue());
|
||||
}
|
||||
}
|
||||
|
||||
private static class IntFormatter implements GuiSlider.FormatHelper {
|
||||
|
||||
public static final IntFormatter INSTANCE = new IntFormatter();
|
||||
|
||||
@Override
|
||||
public String getText(int id, String name, float value) {
|
||||
return name + ": " + (int) value;
|
||||
protected void func_230979_b_() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void func_230972_a_() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//private static class IntFormatter implements GuiSlider.FormatHelper {
|
||||
//
|
||||
// public static final IntFormatter INSTANCE = new IntFormatter();
|
||||
//
|
||||
// @Override
|
||||
// public String getText(int id, String name, float value) {
|
||||
// return name + ": " + (int) value;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.inventory.gui;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
@ -22,6 +23,7 @@ import net.minecraftforge.fml.client.gui.GuiUtils;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class TexturedButton extends Button {
|
||||
|
@ -32,7 +34,7 @@ public class TexturedButton extends Button {
|
|||
public int texturePosY;
|
||||
|
||||
public TexturedButton(ResourceLocation resLoc, int x, int y, int texturePosX, int texturePosY, int width, int height, IPressable pressable) {
|
||||
this(resLoc, x, y, texturePosX, texturePosY, width, height, new ArrayList<>());
|
||||
this(resLoc, x, y, texturePosX, texturePosY, width, height, new ArrayList<>(), pressable);
|
||||
}
|
||||
|
||||
public TexturedButton(ResourceLocation resLoc, int x, int y, int texturePosX, int texturePosY, int width, int height, List<String> hoverTextList, IPressable pressable) {
|
||||
|
@ -44,28 +46,27 @@ public class TexturedButton extends Button {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft minecraft, int x, int y, float f) {
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTicks) {
|
||||
if (this.visible) {
|
||||
minecraft.getTextureManager().bindTexture(this.resLoc);
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(this.resLoc);
|
||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.hovered = x >= this.x && y >= this.y && x < this.x + this.width && y < this.y + this.height;
|
||||
int k = this.getHoverState(this.hovered);
|
||||
if (k == 0) {
|
||||
k = 1;
|
||||
}
|
||||
this.isHovered = mouseX >= this.x && mouseY >= this.y && this.x < this.x + this.width && this.y < this.y + this.height;
|
||||
int k = this.isHovered
|
||||
? 1
|
||||
: 0;
|
||||
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
|
||||
GlStateManager.blendFuncSeparate(770, 771, 1, 0);
|
||||
GlStateManager.blendFunc(770, 771);
|
||||
this.blit(matrices, this.x, this.y, this.texturePosX, this.texturePosY - this.height + k * this.height, this.width, this.height);
|
||||
this.mouseDragged(minecraft, x, y);
|
||||
// this.mouseDragged(minecraft, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawHover(int x, int y) {
|
||||
if (this.isMouseOver()) {
|
||||
public void drawHover(MatrixStack matrices, int x, int y) {
|
||||
if (this.isMouseOver(x, y)) {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
GuiUtils.drawHoveringText(this.textList, x, y, mc.displayWidth, mc.displayHeight, -1, mc.fontRenderer);
|
||||
GuiUtils.drawHoveringText(matrices, this.textList.stream().map(StringTextComponent::new).collect(Collectors.toList()), x, y, mc.currentScreen.width, mc.currentScreen.height, -1, mc.fontRenderer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,31 +14,24 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
|||
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemBattery extends ItemEnergy {
|
||||
|
||||
public ItemBattery(int capacity, int transfer) {
|
||||
super(capacity, transfer);
|
||||
this.setMaxStackSize(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity(ItemStack stack) {
|
||||
return EnumRarity.RARE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -47,21 +40,14 @@ public class ItemBattery extends ItemEnergy {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) {
|
||||
public void inventoryTick(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) {
|
||||
if (!world.isRemote && entity instanceof PlayerEntity && ItemUtil.isEnabled(stack) && !isSelected) {
|
||||
PlayerEntity player = (PlayerEntity) entity;
|
||||
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
|
||||
ItemStack slot = player.inventory.getStackInSlot(i);
|
||||
if (StackUtil.isValid(slot) && slot.getCount() == 1) {
|
||||
int extractable = this.extractEnergy(stack, Integer.MAX_VALUE, true);
|
||||
int received = 0;
|
||||
|
||||
if (slot.hasCapability(CapabilityEnergy.ENERGY, null)) {
|
||||
IEnergyStorage cap = slot.getCapability(CapabilityEnergy.ENERGY, null);
|
||||
if (cap != null) {
|
||||
received = cap.receiveEnergy(extractable, false);
|
||||
}
|
||||
}
|
||||
int received = slot.getCapability(CapabilityEnergy.ENERGY).map(e -> e.receiveEnergy(extractable, false)).orElse(0);
|
||||
|
||||
if (received > 0) {
|
||||
this.extractEnergy(stack, received, false);
|
||||
|
@ -75,17 +61,17 @@ public class ItemBattery extends ItemEnergy {
|
|||
public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity player, Hand hand) {
|
||||
if (!worldIn.isRemote && player.isSneaking()) {
|
||||
ItemUtil.changeEnabled(player, hand);
|
||||
return new ActionResult<>(EnumActionResult.SUCCESS, player.getHeldItem(hand));
|
||||
return ActionResult.resultSuccess(player.getHeldItem(hand));
|
||||
}
|
||||
return super.onItemRightClick(worldIn, player, hand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, World playerIn, List<String> list, ITooltipFlag advanced) {
|
||||
public void addInformation(ItemStack stack, @Nullable World playerIn, List<ITextComponent> list, ITooltipFlag advanced) {
|
||||
super.addInformation(stack, playerIn, list, advanced);
|
||||
list.add(StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".battery." + (ItemUtil.isEnabled(stack)
|
||||
list.add(new TranslationTextComponent("tooltip." + ActuallyAdditions.MODID + ".battery." + (ItemUtil.isEnabled(stack)
|
||||
? "discharge"
|
||||
: "noDischarge")));
|
||||
list.add(StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".battery.changeMode"));
|
||||
list.add(new TranslationTextComponent("tooltip." + ActuallyAdditions.MODID + ".battery.changeMode"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,9 @@ import net.minecraft.util.ActionResult;
|
|||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
@ -75,18 +77,20 @@ public class ItemBooklet extends ItemBase implements IHudDisplay {
|
|||
//TheAchievements.OPEN_BOOKLET.get(player);
|
||||
//TheAchievements.OPEN_BOOKLET_MILESTONE.get(player);
|
||||
}
|
||||
return new ActionResult<>(EnumActionResult.SUCCESS, player.getHeldItem(hand));
|
||||
return ActionResult.resultSuccess(player.getHeldItem(hand));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, @Nullable World playerIn, List<String> tooltip, ITooltipFlag advanced) {
|
||||
tooltip.add(StringUtil.localize("tooltip." + ActuallyAdditions.MODID + "." + this.getBaseName() + ".desc"));
|
||||
public void addInformation(ItemStack stack, @Nullable World playerIn, List<ITextComponent> tooltip, ITooltipFlag advanced) {
|
||||
tooltip.add(new TranslationTextComponent("tooltip." + ActuallyAdditions.MODID + "." + this.getName().getString() + ".desc"));
|
||||
|
||||
// TODO: this is bad
|
||||
for (int i = 1; i <= 4; i++) {
|
||||
String format = i == 4
|
||||
? TextFormatting.GOLD.toString() + TextFormatting.ITALIC
|
||||
: TextFormatting.RESET.toString();
|
||||
tooltip.add(format + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + "." + this.getBaseName() + ".sub." + i));
|
||||
tooltip.add(new TranslationTextComponent("tooltip." + ActuallyAdditions.MODID + "." + this.getName().getString() + ".sub." + i).mergeStyle(i == 4
|
||||
? TextFormatting.GOLD
|
||||
: TextFormatting.RESET).mergeStyle(i == 4
|
||||
? TextFormatting.ITALIC
|
||||
: TextFormatting.RESET));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,99 +1,99 @@
|
|||
/*
|
||||
* This file ("ItemChestToCrateUpgrade.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2017 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.items;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityInventoryBase;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
import net.minecraftforge.items.wrapper.InvWrapper;
|
||||
|
||||
public class ItemChestToCrateUpgrade extends ItemBase {
|
||||
|
||||
private final Class<? extends TileEntity> start;
|
||||
private final BlockState end;
|
||||
|
||||
public ItemChestToCrateUpgrade(String name, Class<? extends TileEntity> start, BlockState end) {
|
||||
super(name);
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUseFirst(PlayerEntity player, World world, BlockPos pos, Direction side, float hitX, float hitY, float hitZ, Hand hand) {
|
||||
ItemStack heldStack = player.getHeldItem(hand);
|
||||
if (player.isSneaking()) {
|
||||
TileEntity tileHit = world.getTileEntity(pos);
|
||||
if (tileHit != null && this.start.isInstance(tileHit)) {
|
||||
if (!world.isRemote) {
|
||||
|
||||
//Copy Slots
|
||||
IItemHandlerModifiable chest = null;
|
||||
if (tileHit instanceof IInventory) {
|
||||
chest = new InvWrapper((IInventory) tileHit);
|
||||
} else if (tileHit instanceof TileEntityInventoryBase) {
|
||||
chest = ((TileEntityInventoryBase) tileHit).inv;
|
||||
}
|
||||
|
||||
if (chest != null) {
|
||||
ItemStack[] stacks = new ItemStack[chest.getSlots()];
|
||||
for (int i = 0; i < stacks.length; i++) {
|
||||
ItemStack aStack = chest.getStackInSlot(i);
|
||||
stacks[i] = aStack.copy();
|
||||
}
|
||||
|
||||
//Set New Block
|
||||
world.playEvent(2001, pos, Block.getStateId(world.getBlockState(pos)));
|
||||
|
||||
world.removeTileEntity(pos);
|
||||
world.setBlockState(pos, this.end, 2);
|
||||
if (!player.isCreative()) {
|
||||
heldStack.shrink(1);
|
||||
}
|
||||
|
||||
//Copy Items into new Chest
|
||||
TileEntity newTileHit = world.getTileEntity(pos);
|
||||
if (newTileHit instanceof TileEntityInventoryBase) {
|
||||
IItemHandlerModifiable newChest = ((TileEntityInventoryBase) newTileHit).inv;
|
||||
|
||||
for (int i = 0; i < stacks.length; i++) {
|
||||
if (StackUtil.isValid(stacks[i])) {
|
||||
if (newChest.getSlots() > i) {
|
||||
newChest.setStackInSlot(i, stacks[i].copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity(ItemStack stack) {
|
||||
return EnumRarity.RARE;
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * This file ("ItemChestToCrateUpgrade.java") is part of the Actually Additions mod for Minecraft.
|
||||
// * It is created and owned by Ellpeck and distributed
|
||||
// * under the Actually Additions License to be found at
|
||||
// * http://ellpeck.de/actaddlicense
|
||||
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
// *
|
||||
// * © 2015-2017 Ellpeck
|
||||
// */
|
||||
//
|
||||
//package de.ellpeck.actuallyadditions.mod.items;
|
||||
//
|
||||
//import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||
//import de.ellpeck.actuallyadditions.mod.tile.TileEntityInventoryBase;
|
||||
//import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
//import net.minecraft.block.Block;
|
||||
//import net.minecraft.entity.player.PlayerEntity;
|
||||
//import net.minecraft.inventory.IInventory;
|
||||
//import net.minecraft.item.EnumRarity;
|
||||
//import net.minecraft.item.ItemStack;
|
||||
//import net.minecraft.tileentity.TileEntity;
|
||||
//import net.minecraft.util.Direction;
|
||||
//import net.minecraft.util.EnumActionResult;
|
||||
//import net.minecraft.util.Hand;
|
||||
//import net.minecraft.util.math.BlockPos;
|
||||
//import net.minecraft.world.World;
|
||||
//import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
//import net.minecraftforge.items.wrapper.InvWrapper;
|
||||
//
|
||||
//public class ItemChestToCrateUpgrade extends ItemBase {
|
||||
//
|
||||
// private final Class<? extends TileEntity> start;
|
||||
// private final BlockState end;
|
||||
//
|
||||
// public ItemChestToCrateUpgrade(String name, Class<? extends TileEntity> start, BlockState end) {
|
||||
// super(name);
|
||||
// this.start = start;
|
||||
// this.end = end;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public EnumActionResult onItemUseFirst(PlayerEntity player, World world, BlockPos pos, Direction side, float hitX, float hitY, float hitZ, Hand hand) {
|
||||
// ItemStack heldStack = player.getHeldItem(hand);
|
||||
// if (player.isSneaking()) {
|
||||
// TileEntity tileHit = world.getTileEntity(pos);
|
||||
// if (tileHit != null && this.start.isInstance(tileHit)) {
|
||||
// if (!world.isRemote) {
|
||||
//
|
||||
// //Copy Slots
|
||||
// IItemHandlerModifiable chest = null;
|
||||
// if (tileHit instanceof IInventory) {
|
||||
// chest = new InvWrapper((IInventory) tileHit);
|
||||
// } else if (tileHit instanceof TileEntityInventoryBase) {
|
||||
// chest = ((TileEntityInventoryBase) tileHit).inv;
|
||||
// }
|
||||
//
|
||||
// if (chest != null) {
|
||||
// ItemStack[] stacks = new ItemStack[chest.getSlots()];
|
||||
// for (int i = 0; i < stacks.length; i++) {
|
||||
// ItemStack aStack = chest.getStackInSlot(i);
|
||||
// stacks[i] = aStack.copy();
|
||||
// }
|
||||
//
|
||||
// //Set New Block
|
||||
// world.playEvent(2001, pos, Block.getStateId(world.getBlockState(pos)));
|
||||
//
|
||||
// world.removeTileEntity(pos);
|
||||
// world.setBlockState(pos, this.end, 2);
|
||||
// if (!player.isCreative()) {
|
||||
// heldStack.shrink(1);
|
||||
// }
|
||||
//
|
||||
// //Copy Items into new Chest
|
||||
// TileEntity newTileHit = world.getTileEntity(pos);
|
||||
// if (newTileHit instanceof TileEntityInventoryBase) {
|
||||
// IItemHandlerModifiable newChest = ((TileEntityInventoryBase) newTileHit).inv;
|
||||
//
|
||||
// for (int i = 0; i < stacks.length; i++) {
|
||||
// if (StackUtil.isValid(stacks[i])) {
|
||||
// if (newChest.getSlots() > i) {
|
||||
// newChest.setStackInSlot(i, stacks[i].copy());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return EnumActionResult.SUCCESS;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return EnumActionResult.PASS;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public EnumRarity getRarity(ItemStack stack) {
|
||||
// return EnumRarity.RARE;
|
||||
// }
|
||||
//}
|
||||
|
|
|
@ -22,7 +22,6 @@ import net.minecraft.entity.EntityLivingBase;
|
|||
import net.minecraft.init.Items;
|
||||
import net.minecraft.init.MobEffects;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
|
@ -102,14 +101,10 @@ public class ItemCoffee extends ItemFoodBase {
|
|||
return EnumAction.DRINK;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public int getMetadata(int damage) {
|
||||
return damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getShareTag() {
|
||||
return true;
|
||||
public CompoundNBT getShareTag(ItemStack stack) {
|
||||
return super.getShareTag(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -134,11 +129,6 @@ public class ItemCoffee extends ItemFoodBase {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity(ItemStack stack) {
|
||||
return EnumRarity.RARE;
|
||||
}
|
||||
|
||||
public static class MilkIngredient extends CoffeeIngredient {
|
||||
|
||||
public MilkIngredient(Ingredient ingredient) {
|
||||
|
|
|
@ -11,18 +11,11 @@
|
|||
package de.ellpeck.actuallyadditions.mod.items;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemFoodBase;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemCoffeeBean extends ItemFoodBase {
|
||||
|
||||
public ItemCoffeeBean() {
|
||||
super(1, 1F, false, name);
|
||||
super(1, 1F, false);
|
||||
this.setMaxDamage(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity(ItemStack stack) {
|
||||
return EnumRarity.RARE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
|||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
|
@ -28,7 +27,7 @@ import net.minecraft.world.World;
|
|||
public class ItemTeleStaff extends ItemEnergy {
|
||||
|
||||
public ItemTeleStaff() {
|
||||
super(250000, 1000, name);
|
||||
super(250000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -72,9 +71,4 @@ public class ItemTeleStaff extends ItemEnergy {
|
|||
player.swingArm(hand);
|
||||
return ActionResult.newResult(EnumActionResult.FAIL, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity(ItemStack stack) {
|
||||
return EnumRarity.EPIC;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,15 +19,16 @@ import net.minecraft.block.BlockState;
|
|||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.SoundEvents;
|
||||
import net.minecraft.particles.ParticleTypes;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
@ -47,27 +48,33 @@ public class ItemWaterBowl extends ItemBase {
|
|||
if (event.getWorld() != null) {
|
||||
if (ConfigBoolValues.WATER_BOWL.isEnabled()) {
|
||||
if (StackUtil.isValid(event.getItemStack()) && event.getItemStack().getItem() == Items.BOWL) {
|
||||
RayTraceResult trace = WorldUtil.getNearestBlockWithDefaultReachDistance(event.getWorld(), event.getPlayer(), true, false, false);
|
||||
RayTraceResult rayTrace = WorldUtil.getNearestBlockWithDefaultReachDistance(event.getWorld(), event.getPlayer(), true, false, false);
|
||||
if (rayTrace.getType() != RayTraceResult.Type.BLOCK) {
|
||||
return;
|
||||
}
|
||||
|
||||
BlockRayTraceResult trace = (BlockRayTraceResult) rayTrace;
|
||||
ActionResult<ItemStack> result = ForgeEventFactory.onBucketUse(event.getPlayer(), event.getWorld(), event.getItemStack(), trace);
|
||||
if (result == null && trace != null && trace.getBlockPos() != null) {
|
||||
if (event.getPlayer().canPlayerEdit(trace.getBlockPos().offset(trace.sideHit), trace.sideHit, event.getItemStack())) {
|
||||
BlockState state = event.getWorld().getBlockState(trace.getBlockPos());
|
||||
if (result == null) {
|
||||
if (event.getPlayer().canPlayerEdit(trace.getPos().offset(trace.getFace()), trace.getFace(), event.getItemStack())) {
|
||||
BlockState state = event.getWorld().getBlockState(trace.getPos());
|
||||
Block block = state.getBlock();
|
||||
|
||||
if ((block == Blocks.WATER || block == Blocks.FLOWING_WATER) && state.getValue(BlockLiquid.LEVEL) == 0) {
|
||||
// TODO: Validate fluid check
|
||||
if ((block == Blocks.WATER) && state.get(BlockStateProperties.LEVEL_0_15) == 0) {
|
||||
event.getPlayer().playSound(SoundEvents.ITEM_BUCKET_FILL, 1.0F, 1.0F);
|
||||
|
||||
if (!event.getWorld().isRemote) {
|
||||
event.getWorld().setBlockState(trace.getBlockPos(), Blocks.AIR.getDefaultState(), 11);
|
||||
event.getWorld().setBlockState(trace.getPos(), Blocks.AIR.getDefaultState(), 11);
|
||||
ItemStack reduced = StackUtil.shrink(event.getItemStack(), 1);
|
||||
|
||||
ItemStack bowl = new ItemStack(ActuallyItems.itemWaterBowl);
|
||||
ItemStack bowl = new ItemStack(ActuallyItems.itemWaterBowl.get());
|
||||
if (!StackUtil.isValid(reduced)) {
|
||||
event.getPlayer().setHeldItem(event.getHand(), bowl);
|
||||
} else if (!event.getPlayer().inventory.addItemStackToInventory(bowl.copy())) {
|
||||
ItemEntity entityItem = new ItemEntity(event.getWorld(), event.getPlayer().posX, event.getPlayer().posY, event.getPlayer().posZ, bowl.copy());
|
||||
ItemEntity entityItem = new ItemEntity(event.getWorld(), event.getPlayer().getPosX(), event.getPlayer().getPosY(), event.getPlayer().getPosZ(), bowl.copy());
|
||||
entityItem.setPickupDelay(0);
|
||||
event.getWorld().spawnEntity(entityItem);
|
||||
event.getWorld().addEntity(entityItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -89,48 +96,49 @@ public class ItemWaterBowl extends ItemBase {
|
|||
}
|
||||
|
||||
if (trace == null) {
|
||||
return new ActionResult<>(EnumActionResult.PASS, stack);
|
||||
} else if (trace.typeOfHit != RayTraceResult.Type.BLOCK) {
|
||||
return new ActionResult<>(EnumActionResult.PASS, stack);
|
||||
return ActionResult.resultPass(stack);
|
||||
} else if (trace.getType() != RayTraceResult.Type.BLOCK) {
|
||||
return ActionResult.resultPass(stack);
|
||||
} else {
|
||||
BlockPos pos = trace.getBlockPos();
|
||||
BlockRayTraceResult blockTrace = (BlockRayTraceResult) trace;
|
||||
BlockPos pos = blockTrace.getPos();
|
||||
|
||||
if (!world.isBlockModifiable(player, pos)) {
|
||||
return new ActionResult<>(EnumActionResult.FAIL, stack);
|
||||
return ActionResult.resultFail(stack);
|
||||
} else {
|
||||
BlockPos pos1 = world.getBlockState(pos).getBlock().isReplaceable(world, pos) && trace.sideHit == Direction.UP
|
||||
BlockPos pos1 = world.getBlockState(pos).getMaterial().isReplaceable() && blockTrace.getFace() == Direction.UP
|
||||
? pos
|
||||
: pos.offset(trace.sideHit);
|
||||
: pos.offset(blockTrace.getFace());
|
||||
|
||||
if (!player.canPlayerEdit(pos1, trace.sideHit, stack)) {
|
||||
return new ActionResult<>(EnumActionResult.FAIL, stack);
|
||||
if (!player.canPlayerEdit(pos1, blockTrace.getFace(), stack)) {
|
||||
return ActionResult.resultFail(stack);
|
||||
} else if (this.tryPlaceContainedLiquid(player, world, pos1, false)) {
|
||||
return !player.isCreative()
|
||||
? new ActionResult<>(EnumActionResult.SUCCESS, new ItemStack(Items.BOWL))
|
||||
: new ActionResult<>(EnumActionResult.SUCCESS, stack);
|
||||
? ActionResult.resultSuccess(new ItemStack(Items.BOWL))
|
||||
: ActionResult.resultSuccess(stack);
|
||||
} else {
|
||||
return new ActionResult<>(EnumActionResult.FAIL, stack);
|
||||
return ActionResult.resultFail(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) {
|
||||
public void inventoryTick(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) {
|
||||
if (!world.isRemote) {
|
||||
if (ConfigBoolValues.WATER_BOWL_LOSS.isEnabled()) {
|
||||
if (world.getTotalWorldTime() % 10 == 0 && world.rand.nextFloat() >= 0.5F) {
|
||||
if (world.getGameTime() % 10 == 0 && world.rand.nextFloat() >= 0.5F) {
|
||||
int lastX = 0;
|
||||
int lastY = 0;
|
||||
|
||||
if (stack.hasTagCompound()) {
|
||||
CompoundNBT compound = stack.getTagCompound();
|
||||
if (stack.hasTag()) {
|
||||
CompoundNBT compound = stack.getOrCreateTag();
|
||||
lastX = compound.getInt("lastX");
|
||||
lastY = compound.getInt("lastY");
|
||||
}
|
||||
|
||||
boolean change = false;
|
||||
if (lastX != 0 && lastX != (int) entity.posX || lastY != 0 && lastY != (int) entity.posY) {
|
||||
if (lastX != 0 && lastX != (int) entity.getPosX() || lastY != 0 && lastY != (int) entity.getPosY()) {
|
||||
if (!entity.isSneaking()) {
|
||||
if (entity instanceof PlayerEntity) {
|
||||
PlayerEntity player = (PlayerEntity) entity;
|
||||
|
@ -143,13 +151,9 @@ public class ItemWaterBowl extends ItemBase {
|
|||
}
|
||||
|
||||
if (change || lastX == 0 || lastY == 0) {
|
||||
if (!stack.hasTagCompound()) {
|
||||
stack.setTagCompound(new CompoundNBT());
|
||||
}
|
||||
|
||||
CompoundNBT compound = stack.getTagCompound();
|
||||
compound.putInt("lastX", (int) entity.posX);
|
||||
compound.putInt("lastY", (int) entity.posY);
|
||||
CompoundNBT compound = stack.getOrCreateTag();
|
||||
compound.putInt("lastX", (int) entity.getPosX());
|
||||
compound.putInt("lastY", (int) entity.getPosY());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -173,16 +177,16 @@ public class ItemWaterBowl extends ItemBase {
|
|||
BlockState state = world.getBlockState(pos);
|
||||
Material material = state.getMaterial();
|
||||
boolean nonSolid = !material.isSolid();
|
||||
boolean replaceable = state.getBlock().isReplaceable(world, pos);
|
||||
boolean replaceable = state.getMaterial().isReplaceable();
|
||||
|
||||
if (!world.isAirBlock(pos) && !nonSolid && !replaceable) {
|
||||
return false;
|
||||
} else {
|
||||
if (world.provider.doesWaterVaporize()) {
|
||||
if (world.getDimensionType().isUltrawarm()) {
|
||||
world.playSound(player, pos, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
|
||||
|
||||
for (int k = 0; k < 8; k++) {
|
||||
world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, pos.getX() + Math.random(), pos.getY() + Math.random(), pos.getZ() + Math.random(), 0.0D, 0.0D, 0.0D);
|
||||
world.addParticle(ParticleTypes.LARGE_SMOKE, pos.getX() + Math.random(), pos.getY() + Math.random(), pos.getZ() + Math.random(), 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
} else {
|
||||
if (!world.isRemote && (nonSolid || replaceable) && !material.isLiquid()) {
|
||||
|
@ -191,12 +195,7 @@ public class ItemWaterBowl extends ItemBase {
|
|||
|
||||
world.playSound(player, pos, SoundEvents.ITEM_BUCKET_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
|
||||
BlockState placeState;
|
||||
if (finite) {
|
||||
placeState = Blocks.FLOWING_WATER.getDefaultState();
|
||||
} else {
|
||||
placeState = Blocks.FLOWING_WATER.getDefaultState();
|
||||
}
|
||||
BlockState placeState = Blocks.WATER.getDefaultState();
|
||||
world.setBlockState(pos, placeState, 3);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,10 +13,9 @@ package de.ellpeck.actuallyadditions.mod.items;
|
|||
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
@ -25,17 +24,16 @@ import net.minecraft.world.World;
|
|||
public class ItemWaterRemovalRing extends ItemEnergy {
|
||||
|
||||
public ItemWaterRemovalRing() {
|
||||
super(800000, 1000, name);
|
||||
super(800000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) {
|
||||
if (!(entity instanceof PlayerEntity) || world.isRemote || entity.isSneaking()) {
|
||||
public void inventoryTick(ItemStack stack, World world, Entity player, int itemSlot, boolean isSelected) {
|
||||
if (!(player instanceof PlayerEntity) || player.world.isRemote || player.isSneaking()) {
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerEntity player = (PlayerEntity) entity;
|
||||
ItemStack equipped = player.getHeldItemMainhand();
|
||||
ItemStack equipped = ((PlayerEntity) player).getHeldItemMainhand();
|
||||
|
||||
int energyUse = 150;
|
||||
if (StackUtil.isValid(equipped) && equipped == stack && this.getEnergyStored(stack) >= energyUse) {
|
||||
|
@ -45,25 +43,27 @@ public class ItemWaterRemovalRing extends ItemEnergy {
|
|||
for (int x = -range; x < range + 1; x++) {
|
||||
for (int z = -range; z < range + 1; z++) {
|
||||
for (int y = -range; y < range + 1; y++) {
|
||||
int theX = MathHelper.floor(player.posX + x);
|
||||
int theY = MathHelper.floor(player.posY + y);
|
||||
int theZ = MathHelper.floor(player.posZ + z);
|
||||
int theX = MathHelper.floor(player.getPosX() + x);
|
||||
int theY = MathHelper.floor(player.getPosY() + y);
|
||||
int theZ = MathHelper.floor(player.getPosZ() + z);
|
||||
|
||||
//Remove Water
|
||||
BlockPos pos = new BlockPos(theX, theY, theZ);
|
||||
Block block = world.getBlockState(pos).getBlock();
|
||||
if ((block == Blocks.WATER || block == Blocks.FLOWING_WATER) && this.getEnergyStored(stack) >= energyUse) {
|
||||
// TODO: Ensure water check is correct
|
||||
if ((block == Blocks.WATER) && this.getEnergyStored(stack) >= energyUse) {
|
||||
world.setBlockState(pos, Blocks.AIR.getDefaultState());
|
||||
|
||||
if (!player.isCreative()) {
|
||||
if (!((PlayerEntity) player).isCreative()) {
|
||||
this.extractEnergyInternal(stack, energyUse, false);
|
||||
}
|
||||
}
|
||||
//Remove Lava
|
||||
else if ((block == Blocks.LAVA || block == Blocks.FLOWING_LAVA) && this.getEnergyStored(stack) >= energyUse * 2) {
|
||||
// TODO: Ensure lava check is correct
|
||||
else if ((block == Blocks.LAVA) && this.getEnergyStored(stack) >= energyUse * 2) {
|
||||
world.setBlockState(pos, Blocks.AIR.getDefaultState());
|
||||
|
||||
if (!player.isCreative()) {
|
||||
if (!((PlayerEntity) player).isCreative()) {
|
||||
this.extractEnergyInternal(stack, energyUse * 2, false);
|
||||
}
|
||||
}
|
||||
|
@ -72,9 +72,4 @@ public class ItemWaterRemovalRing extends ItemEnergy {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity(ItemStack stack) {
|
||||
return EnumRarity.EPIC;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,92 +1,92 @@
|
|||
/*
|
||||
* This file ("JEIActuallyAdditionsPlugin.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2017 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.jei;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiCoffeeMachine;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiFurnaceDouble;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiGrinder;
|
||||
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
||||
import de.ellpeck.actuallyadditions.mod.jei.booklet.BookletRecipeCategory;
|
||||
import de.ellpeck.actuallyadditions.mod.jei.booklet.BookletRecipeWrapper;
|
||||
import de.ellpeck.actuallyadditions.mod.jei.coffee.CoffeeMachineRecipeCategory;
|
||||
import de.ellpeck.actuallyadditions.mod.jei.coffee.CoffeeMachineRecipeWrapper;
|
||||
import de.ellpeck.actuallyadditions.mod.jei.crusher.CrusherRecipeCategory;
|
||||
import de.ellpeck.actuallyadditions.mod.jei.crusher.CrusherRecipeWrapper;
|
||||
import de.ellpeck.actuallyadditions.mod.jei.empowerer.EmpowererRecipeCategory;
|
||||
import de.ellpeck.actuallyadditions.mod.jei.empowerer.EmpowererRecipeWrapper;
|
||||
import de.ellpeck.actuallyadditions.mod.jei.reconstructor.ReconstructorRecipeCategory;
|
||||
import de.ellpeck.actuallyadditions.mod.jei.reconstructor.ReconstructorRecipeWrapper;
|
||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||
import mezz.jei.api.IModPlugin;
|
||||
import mezz.jei.api.constants.VanillaRecipeCategoryUid;
|
||||
import mezz.jei.api.helpers.IJeiHelpers;
|
||||
import mezz.jei.api.registration.IRecipeCategoryRegistration;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@JEIPlugin
|
||||
public class JEIActuallyAdditionsPlugin implements IModPlugin {
|
||||
|
||||
@Override
|
||||
public void registerCategories(IRecipeCategoryRegistration registry) {
|
||||
IJeiHelpers helpers = registry.getJeiHelpers();
|
||||
registry.addRecipeCategories(new CoffeeMachineRecipeCategory(helpers.getGuiHelper()), new CompostRecipeCategory(helpers.getGuiHelper()), new CrusherRecipeCategory(helpers.getGuiHelper()), new ReconstructorRecipeCategory(helpers.getGuiHelper()), new EmpowererRecipeCategory(helpers.getGuiHelper()), new BookletRecipeCategory(helpers.getGuiHelper()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(IModRegistry registry) {
|
||||
IJeiHelpers helpers = registry.getJeiHelpers();
|
||||
|
||||
registry.handleRecipes(IBookletPage.class, BookletRecipeWrapper::new, BookletRecipeCategory.NAME);
|
||||
registry.handleRecipes(CoffeeIngredient.class, CoffeeMachineRecipeWrapper::new, CoffeeMachineRecipeCategory.NAME);
|
||||
registry.handleRecipes(CrusherRecipe.class, CrusherRecipeWrapper::new, CrusherRecipeCategory.NAME);
|
||||
registry.handleRecipes(LensConversionRecipe.class, ReconstructorRecipeWrapper.FACTORY, ReconstructorRecipeCategory.NAME);
|
||||
registry.handleRecipes(EmpowererRecipe.class, EmpowererRecipeWrapper::new, EmpowererRecipeCategory.NAME);
|
||||
registry.handleRecipes(CompostRecipe.class, CompostRecipeWrapper::new, CompostRecipeCategory.NAME);
|
||||
|
||||
registry.addRecipes(ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA, BookletRecipeCategory.NAME);
|
||||
registry.addRecipes(ActuallyAdditionsAPI.COFFEE_MACHINE_INGREDIENTS, CoffeeMachineRecipeCategory.NAME);
|
||||
registry.addRecipes(ActuallyAdditionsAPI.CRUSHER_RECIPES, CrusherRecipeCategory.NAME);
|
||||
registry.addRecipes(ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES, ReconstructorRecipeCategory.NAME);
|
||||
registry.addRecipes(ActuallyAdditionsAPI.EMPOWERER_RECIPES, EmpowererRecipeCategory.NAME);
|
||||
registry.addRecipes(ActuallyAdditionsAPI.COMPOST_RECIPES, CompostRecipeCategory.NAME);
|
||||
|
||||
registry.addRecipeClickArea(GuiCoffeeMachine.class, 53, 42, 22, 16, CoffeeMachineRecipeCategory.NAME);
|
||||
registry.addRecipeClickArea(GuiGrinder.class, 80, 40, 24, 22, CrusherRecipeCategory.NAME);
|
||||
registry.addRecipeClickArea(GuiGrinder.GuiGrinderDouble.class, 51, 40, 74, 22, CrusherRecipeCategory.NAME);
|
||||
registry.addRecipeClickArea(GuiFurnaceDouble.class, 51, 40, 74, 22, VanillaRecipeCategoryUid.SMELTING);
|
||||
|
||||
IIngredientBlacklist blacklist = helpers.getIngredientBlacklist();
|
||||
blacklist.addIngredientToBlacklist(new ItemStack(ActuallyBlocks.blockRice.get()));
|
||||
blacklist.addIngredientToBlacklist(new ItemStack(ActuallyBlocks.blockCanola.get()));
|
||||
blacklist.addIngredientToBlacklist(new ItemStack(ActuallyBlocks.blockFlax.get()));
|
||||
blacklist.addIngredientToBlacklist(new ItemStack(ActuallyBlocks.blockCoffee.get()));
|
||||
blacklist.addIngredientToBlacklist(new ItemStack(ActuallyBlocks.blockWildPlant.get(), 1, Util.WILDCARD));
|
||||
blacklist.addIngredientToBlacklist(new ItemStack(ActuallyBlocks.blockColoredLampOn.get(), 1, Util.WILDCARD));
|
||||
// blacklist.addIngredientToBlacklist(new ItemStack(InitItems.itemMisc.get(), 1, TheMiscItems.YOUTUBE_ICON.ordinal()));
|
||||
|
||||
registry.addRecipeCatalyst(new ItemStack(ActuallyItems.itemCrafterOnAStick.get()), VanillaRecipeCategoryUid.CRAFTING);
|
||||
registry.addRecipeCatalyst(new ItemStack(ActuallyBlocks.blockFurnaceDouble.get()), VanillaRecipeCategoryUid.SMELTING);
|
||||
registry.addRecipeCatalyst(new ItemStack(ActuallyBlocks.blockGrinder.get()), CrusherRecipeCategory.NAME);
|
||||
registry.addRecipeCatalyst(new ItemStack(ActuallyBlocks.blockGrinderDouble.get()), CrusherRecipeCategory.NAME);
|
||||
registry.addRecipeCatalyst(new ItemStack(ActuallyBlocks.blockCoffeeMachine.get()), CoffeeMachineRecipeCategory.NAME);
|
||||
registry.addRecipeCatalyst(new ItemStack(ActuallyBlocks.blockAtomicReconstructor.get()), ReconstructorRecipeCategory.NAME);
|
||||
registry.addRecipeCatalyst(new ItemStack(ActuallyBlocks.blockEmpowerer.get()), EmpowererRecipeCategory.NAME);
|
||||
registry.addRecipeCatalyst(new ItemStack(ActuallyItems.itemBooklet.get()), BookletRecipeCategory.NAME);
|
||||
// registry.addRecipeCatalyst(new ItemStack(InitBlocks.blockCompost.get()), CompostRecipeCategory.NAME);
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * This file ("JEIActuallyAdditionsPlugin.java") is part of the Actually Additions mod for Minecraft.
|
||||
// * It is created and owned by Ellpeck and distributed
|
||||
// * under the Actually Additions License to be found at
|
||||
// * http://ellpeck.de/actaddlicense
|
||||
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
// *
|
||||
// * © 2015-2017 Ellpeck
|
||||
// */
|
||||
//
|
||||
//package de.ellpeck.actuallyadditions.mod.jei;
|
||||
//
|
||||
//import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
//import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
||||
//import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient;
|
||||
//import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
|
||||
//import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe;
|
||||
//import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
|
||||
//import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||
//import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiCoffeeMachine;
|
||||
//import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiFurnaceDouble;
|
||||
//import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiGrinder;
|
||||
//import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
||||
//import de.ellpeck.actuallyadditions.mod.jei.booklet.BookletRecipeCategory;
|
||||
//import de.ellpeck.actuallyadditions.mod.jei.booklet.BookletRecipeWrapper;
|
||||
//import de.ellpeck.actuallyadditions.mod.jei.coffee.CoffeeMachineRecipeCategory;
|
||||
//import de.ellpeck.actuallyadditions.mod.jei.coffee.CoffeeMachineRecipeWrapper;
|
||||
//import de.ellpeck.actuallyadditions.mod.jei.crusher.CrusherRecipeCategory;
|
||||
//import de.ellpeck.actuallyadditions.mod.jei.crusher.CrusherRecipeWrapper;
|
||||
//import de.ellpeck.actuallyadditions.mod.jei.empowerer.EmpowererRecipeCategory;
|
||||
//import de.ellpeck.actuallyadditions.mod.jei.empowerer.EmpowererRecipeWrapper;
|
||||
//import de.ellpeck.actuallyadditions.mod.jei.reconstructor.ReconstructorRecipeCategory;
|
||||
//import de.ellpeck.actuallyadditions.mod.jei.reconstructor.ReconstructorRecipeWrapper;
|
||||
//import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||
//import mezz.jei.api.IModPlugin;
|
||||
//import mezz.jei.api.constants.VanillaRecipeCategoryUid;
|
||||
//import mezz.jei.api.helpers.IJeiHelpers;
|
||||
//import mezz.jei.api.registration.IRecipeCategoryRegistration;
|
||||
//import net.minecraft.item.ItemStack;
|
||||
//
|
||||
//@JEIPlugin
|
||||
//public class JEIActuallyAdditionsPlugin implements IModPlugin {
|
||||
//
|
||||
// @Override
|
||||
// public void registerCategories(IRecipeCategoryRegistration registry) {
|
||||
// IJeiHelpers helpers = registry.getJeiHelpers();
|
||||
// registry.addRecipeCategories(new CoffeeMachineRecipeCategory(helpers.getGuiHelper()), new CompostRecipeCategory(helpers.getGuiHelper()), new CrusherRecipeCategory(helpers.getGuiHelper()), new ReconstructorRecipeCategory(helpers.getGuiHelper()), new EmpowererRecipeCategory(helpers.getGuiHelper()), new BookletRecipeCategory(helpers.getGuiHelper()));
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void register(IModRegistry registry) {
|
||||
// IJeiHelpers helpers = registry.getJeiHelpers();
|
||||
//
|
||||
// registry.handleRecipes(IBookletPage.class, BookletRecipeWrapper::new, BookletRecipeCategory.NAME);
|
||||
// registry.handleRecipes(CoffeeIngredient.class, CoffeeMachineRecipeWrapper::new, CoffeeMachineRecipeCategory.NAME);
|
||||
// registry.handleRecipes(CrusherRecipe.class, CrusherRecipeWrapper::new, CrusherRecipeCategory.NAME);
|
||||
// registry.handleRecipes(LensConversionRecipe.class, ReconstructorRecipeWrapper.FACTORY, ReconstructorRecipeCategory.NAME);
|
||||
// registry.handleRecipes(EmpowererRecipe.class, EmpowererRecipeWrapper::new, EmpowererRecipeCategory.NAME);
|
||||
// registry.handleRecipes(CompostRecipe.class, CompostRecipeWrapper::new, CompostRecipeCategory.NAME);
|
||||
//
|
||||
// registry.addRecipes(ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA, BookletRecipeCategory.NAME);
|
||||
// registry.addRecipes(ActuallyAdditionsAPI.COFFEE_MACHINE_INGREDIENTS, CoffeeMachineRecipeCategory.NAME);
|
||||
// registry.addRecipes(ActuallyAdditionsAPI.CRUSHER_RECIPES, CrusherRecipeCategory.NAME);
|
||||
// registry.addRecipes(ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES, ReconstructorRecipeCategory.NAME);
|
||||
// registry.addRecipes(ActuallyAdditionsAPI.EMPOWERER_RECIPES, EmpowererRecipeCategory.NAME);
|
||||
// registry.addRecipes(ActuallyAdditionsAPI.COMPOST_RECIPES, CompostRecipeCategory.NAME);
|
||||
//
|
||||
// registry.addRecipeClickArea(GuiCoffeeMachine.class, 53, 42, 22, 16, CoffeeMachineRecipeCategory.NAME);
|
||||
// registry.addRecipeClickArea(GuiGrinder.class, 80, 40, 24, 22, CrusherRecipeCategory.NAME);
|
||||
// registry.addRecipeClickArea(GuiGrinder.GuiGrinderDouble.class, 51, 40, 74, 22, CrusherRecipeCategory.NAME);
|
||||
// registry.addRecipeClickArea(GuiFurnaceDouble.class, 51, 40, 74, 22, VanillaRecipeCategoryUid.SMELTING);
|
||||
//
|
||||
// IIngredientBlacklist blacklist = helpers.getIngredientBlacklist();
|
||||
// blacklist.addIngredientToBlacklist(new ItemStack(ActuallyBlocks.blockRice.get()));
|
||||
// blacklist.addIngredientToBlacklist(new ItemStack(ActuallyBlocks.blockCanola.get()));
|
||||
// blacklist.addIngredientToBlacklist(new ItemStack(ActuallyBlocks.blockFlax.get()));
|
||||
// blacklist.addIngredientToBlacklist(new ItemStack(ActuallyBlocks.blockCoffee.get()));
|
||||
// blacklist.addIngredientToBlacklist(new ItemStack(ActuallyBlocks.blockWildPlant.get(), 1, Util.WILDCARD));
|
||||
// blacklist.addIngredientToBlacklist(new ItemStack(ActuallyBlocks.blockColoredLampOn.get(), 1, Util.WILDCARD));
|
||||
// // blacklist.addIngredientToBlacklist(new ItemStack(InitItems.itemMisc.get(), 1, TheMiscItems.YOUTUBE_ICON.ordinal()));
|
||||
//
|
||||
// registry.addRecipeCatalyst(new ItemStack(ActuallyItems.itemCrafterOnAStick.get()), VanillaRecipeCategoryUid.CRAFTING);
|
||||
// registry.addRecipeCatalyst(new ItemStack(ActuallyBlocks.blockFurnaceDouble.get()), VanillaRecipeCategoryUid.SMELTING);
|
||||
// registry.addRecipeCatalyst(new ItemStack(ActuallyBlocks.blockGrinder.get()), CrusherRecipeCategory.NAME);
|
||||
// registry.addRecipeCatalyst(new ItemStack(ActuallyBlocks.blockGrinderDouble.get()), CrusherRecipeCategory.NAME);
|
||||
// registry.addRecipeCatalyst(new ItemStack(ActuallyBlocks.blockCoffeeMachine.get()), CoffeeMachineRecipeCategory.NAME);
|
||||
// registry.addRecipeCatalyst(new ItemStack(ActuallyBlocks.blockAtomicReconstructor.get()), ReconstructorRecipeCategory.NAME);
|
||||
// registry.addRecipeCatalyst(new ItemStack(ActuallyBlocks.blockEmpowerer.get()), EmpowererRecipeCategory.NAME);
|
||||
// registry.addRecipeCatalyst(new ItemStack(ActuallyItems.itemBooklet.get()), BookletRecipeCategory.NAME);
|
||||
// // registry.addRecipeCatalyst(new ItemStack(InitBlocks.blockCompost.get()), CompostRecipeCategory.NAME);
|
||||
// }
|
||||
//}
|
||||
|
|
|
@ -1,68 +1,68 @@
|
|||
/*
|
||||
* This file ("RecipeWrapperWithButton.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2017 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.jei;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.gui.TexturedButton;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class RecipeWrapperWithButton implements IRecipeWr {
|
||||
|
||||
protected final TexturedButton theButton;
|
||||
|
||||
public RecipeWrapperWithButton() {
|
||||
this.theButton = new TexturedButton(GuiBooklet.RES_LOC_GADGETS, this.getButtonX(), this.getButtonY(), 0, 0, 20, 20, btn -> {
|
||||
});
|
||||
}
|
||||
|
||||
public abstract int getButtonX();
|
||||
|
||||
public abstract int getButtonY();
|
||||
|
||||
@Override
|
||||
public boolean handleClick(Minecraft minecraft, int mouseX, int mouseY, int mouseButton) {
|
||||
if (this.theButton.mousePressed(minecraft, mouseX, mouseY)) {
|
||||
this.theButton.playPressSound(minecraft.getSoundHandler());
|
||||
|
||||
IBookletPage page = this.getPage();
|
||||
if (page != null) {
|
||||
Minecraft.getInstance().displayGuiScreen(BookletUtils.createBookletGuiFromPage(Minecraft.getInstance().currentScreen, page));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public abstract IBookletPage getPage();
|
||||
|
||||
@Override
|
||||
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
|
||||
this.theButton.drawButton(minecraft, mouseX, mouseY, 0F);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<String> getTooltipStrings(int mouseX, int mouseY) {
|
||||
if (this.theButton.isMouseOver()) {
|
||||
return Collections.singletonList(StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".clickToSeeRecipe"));
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * This file ("RecipeWrapperWithButton.java") is part of the Actually Additions mod for Minecraft.
|
||||
// * It is created and owned by Ellpeck and distributed
|
||||
// * under the Actually Additions License to be found at
|
||||
// * http://ellpeck.de/actaddlicense
|
||||
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
// *
|
||||
// * © 2015-2017 Ellpeck
|
||||
// */
|
||||
//
|
||||
//package de.ellpeck.actuallyadditions.mod.jei;
|
||||
//
|
||||
//import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
||||
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
//import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
|
||||
//import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
|
||||
//import de.ellpeck.actuallyadditions.mod.inventory.gui.TexturedButton;
|
||||
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
//import net.minecraft.client.Minecraft;
|
||||
//
|
||||
//import javax.annotation.Nullable;
|
||||
//import java.util.Collections;
|
||||
//import java.util.List;
|
||||
//
|
||||
//public abstract class RecipeWrapperWithButton implements IRecipeWr {
|
||||
//
|
||||
// protected final TexturedButton theButton;
|
||||
//
|
||||
// public RecipeWrapperWithButton() {
|
||||
// this.theButton = new TexturedButton(GuiBooklet.RES_LOC_GADGETS, this.getButtonX(), this.getButtonY(), 0, 0, 20, 20, btn -> {
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// public abstract int getButtonX();
|
||||
//
|
||||
// public abstract int getButtonY();
|
||||
//
|
||||
// @Override
|
||||
// public boolean handleClick(Minecraft minecraft, int mouseX, int mouseY, int mouseButton) {
|
||||
// if (this.theButton.mousePressed(minecraft, mouseX, mouseY)) {
|
||||
// this.theButton.playPressSound(minecraft.getSoundHandler());
|
||||
//
|
||||
// IBookletPage page = this.getPage();
|
||||
// if (page != null) {
|
||||
// Minecraft.getInstance().displayGuiScreen(BookletUtils.createBookletGuiFromPage(Minecraft.getInstance().currentScreen, page));
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// public abstract IBookletPage getPage();
|
||||
//
|
||||
// @Override
|
||||
// public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
|
||||
// this.theButton.drawButton(minecraft, mouseX, mouseY, 0F);
|
||||
// }
|
||||
//
|
||||
// @Nullable
|
||||
// @Override
|
||||
// public List<String> getTooltipStrings(int mouseX, int mouseY) {
|
||||
// if (this.theButton.isMouseOver()) {
|
||||
// return Collections.singletonList(StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".clickToSeeRecipe"));
|
||||
// } else {
|
||||
// return Collections.emptyList();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
|
|
@ -1,63 +1,63 @@
|
|||
/*
|
||||
* This file ("BookletRecipeCategory.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2017 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.jei.booklet;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.gui.IDrawable;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.IRecipeCategory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class BookletRecipeCategory implements IRecipeCategory<BookletRecipeWrapper> {
|
||||
|
||||
public static final String NAME = "actuallyadditions.booklet";
|
||||
|
||||
private final IDrawable background;
|
||||
|
||||
public BookletRecipeCategory(IGuiHelper helper) {
|
||||
this.background = helper.createBlankDrawable(160, 105);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUid() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return StringUtil.localize("container.nei." + NAME + ".name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModName() {
|
||||
return ActuallyAdditions.NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return this.background;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout recipeLayout, BookletRecipeWrapper wrapper, IIngredients ingredients) {
|
||||
recipeLayout.getItemStacks().init(0, true, 70, -4);
|
||||
|
||||
List<ItemStack> list = new ArrayList<>();
|
||||
wrapper.thePage.getItemStacksForPage(list);
|
||||
recipeLayout.getItemStacks().set(0, list);
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * This file ("BookletRecipeCategory.java") is part of the Actually Additions mod for Minecraft.
|
||||
// * It is created and owned by Ellpeck and distributed
|
||||
// * under the Actually Additions License to be found at
|
||||
// * http://ellpeck.de/actaddlicense
|
||||
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
// *
|
||||
// * © 2015-2017 Ellpeck
|
||||
// */
|
||||
//
|
||||
//package de.ellpeck.actuallyadditions.mod.jei.booklet;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.List;
|
||||
//
|
||||
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
//import mezz.jei.api.IGuiHelper;
|
||||
//import mezz.jei.api.gui.IDrawable;
|
||||
//import mezz.jei.api.gui.IRecipeLayout;
|
||||
//import mezz.jei.api.ingredients.IIngredients;
|
||||
//import mezz.jei.api.recipe.IRecipeCategory;
|
||||
//import net.minecraft.item.ItemStack;
|
||||
//
|
||||
//public class BookletRecipeCategory implements IRecipeCategory<BookletRecipeWrapper> {
|
||||
//
|
||||
// public static final String NAME = "actuallyadditions.booklet";
|
||||
//
|
||||
// private final IDrawable background;
|
||||
//
|
||||
// public BookletRecipeCategory(IGuiHelper helper) {
|
||||
// this.background = helper.createBlankDrawable(160, 105);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getUid() {
|
||||
// return NAME;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getTitle() {
|
||||
// return StringUtil.localize("container.nei." + NAME + ".name");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getModName() {
|
||||
// return ActuallyAdditions.NAME;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public IDrawable getBackground() {
|
||||
// return this.background;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void setRecipe(IRecipeLayout recipeLayout, BookletRecipeWrapper wrapper, IIngredients ingredients) {
|
||||
// recipeLayout.getItemStacks().init(0, true, 70, -4);
|
||||
//
|
||||
// List<ItemStack> list = new ArrayList<>();
|
||||
// wrapper.thePage.getItemStacksForPage(list);
|
||||
// recipeLayout.getItemStacks().set(0, list);
|
||||
// }
|
||||
//}
|
||||
|
|
|
@ -1,83 +1,83 @@
|
|||
/*
|
||||
* This file ("BookletRecipeWrapper.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2017 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.jei.booklet;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.jei.RecipeWrapperWithButton;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.ingredients.VanillaTypes;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class BookletRecipeWrapper extends RecipeWrapperWithButton {
|
||||
|
||||
public final IBookletPage thePage;
|
||||
|
||||
public BookletRecipeWrapper(IBookletPage page) {
|
||||
this.thePage = page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getIngredients(IIngredients ingredients) {
|
||||
List<ItemStack> itemList = new ArrayList<>();
|
||||
this.thePage.getItemStacksForPage(itemList);
|
||||
ingredients.setInputs(VanillaTypes.ITEM, itemList);
|
||||
ingredients.setOutputs(VanillaTypes.ITEM, itemList);
|
||||
|
||||
List<FluidStack> fluidList = new ArrayList<>();
|
||||
this.thePage.getFluidStacksForPage(fluidList);
|
||||
ingredients.setInputs(VanillaTypes.FLUID, fluidList);
|
||||
ingredients.setOutputs(VanillaTypes.FLUID, fluidList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
|
||||
List<String> header = minecraft.fontRenderer.listFormattedStringToWidth(StringUtil.localize("container.nei." + ActuallyAdditions.MODID + ".booklet.header").replaceAll("<item>", TextFormatting.BLUE + "").replaceAll("<r>", TextFormatting.BLACK + ""), 150);
|
||||
for (int i = 0; i < header.size(); i++) {
|
||||
minecraft.fontRenderer.drawString(header.get(i), 0, 17 + i * (minecraft.fontRenderer.FONT_HEIGHT + 1), 0, false);
|
||||
}
|
||||
|
||||
int maxLines = 4;
|
||||
IBookletChapter chapter = this.thePage.getChapter();
|
||||
String aText = chapter.getAllPages()[0].getInfoText();
|
||||
List<String> text = minecraft.fontRenderer.listFormattedStringToWidth(aText != null ? aText : TextFormatting.DARK_RED + StringUtil.localize("container.nei." + ActuallyAdditions.MODID + ".booklet.noText"), 150);
|
||||
for (int i = 0; i < Math.min(maxLines, text.size()); i++) {
|
||||
minecraft.fontRenderer.drawString(text.get(i) + (i == maxLines - 1 && text.size() > maxLines ? TextFormatting.RESET + "" + TextFormatting.BLACK + "..." : ""), 0, 16 + 25 + i * (minecraft.fontRenderer.FONT_HEIGHT + 1), 0, false);
|
||||
}
|
||||
minecraft.fontRenderer.drawString(TextFormatting.ITALIC + chapter.getLocalizedName(), 25, 85, 0, false);
|
||||
minecraft.fontRenderer.drawString(TextFormatting.ITALIC + "Page " + (chapter.getPageIndex(this.thePage) + 1), 25, 95, 0, false);
|
||||
|
||||
super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getButtonX() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getButtonY() {
|
||||
return 84;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBookletPage getPage() {
|
||||
return this.thePage;
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * This file ("BookletRecipeWrapper.java") is part of the Actually Additions mod for Minecraft.
|
||||
// * It is created and owned by Ellpeck and distributed
|
||||
// * under the Actually Additions License to be found at
|
||||
// * http://ellpeck.de/actaddlicense
|
||||
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
// *
|
||||
// * © 2015-2017 Ellpeck
|
||||
// */
|
||||
//
|
||||
//package de.ellpeck.actuallyadditions.mod.jei.booklet;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.List;
|
||||
//
|
||||
//import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
|
||||
//import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
||||
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
//import de.ellpeck.actuallyadditions.mod.jei.RecipeWrapperWithButton;
|
||||
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
//import mezz.jei.api.ingredients.IIngredients;
|
||||
//import mezz.jei.api.ingredients.VanillaTypes;
|
||||
//import net.minecraft.client.Minecraft;
|
||||
//import net.minecraft.item.ItemStack;
|
||||
//import net.minecraft.util.text.TextFormatting;
|
||||
//import net.minecraftforge.fluids.FluidStack;
|
||||
//
|
||||
//public class BookletRecipeWrapper extends RecipeWrapperWithButton {
|
||||
//
|
||||
// public final IBookletPage thePage;
|
||||
//
|
||||
// public BookletRecipeWrapper(IBookletPage page) {
|
||||
// this.thePage = page;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void getIngredients(IIngredients ingredients) {
|
||||
// List<ItemStack> itemList = new ArrayList<>();
|
||||
// this.thePage.getItemStacksForPage(itemList);
|
||||
// ingredients.setInputs(VanillaTypes.ITEM, itemList);
|
||||
// ingredients.setOutputs(VanillaTypes.ITEM, itemList);
|
||||
//
|
||||
// List<FluidStack> fluidList = new ArrayList<>();
|
||||
// this.thePage.getFluidStacksForPage(fluidList);
|
||||
// ingredients.setInputs(VanillaTypes.FLUID, fluidList);
|
||||
// ingredients.setOutputs(VanillaTypes.FLUID, fluidList);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
|
||||
// List<String> header = minecraft.fontRenderer.listFormattedStringToWidth(StringUtil.localize("container.nei." + ActuallyAdditions.MODID + ".booklet.header").replaceAll("<item>", TextFormatting.BLUE + "").replaceAll("<r>", TextFormatting.BLACK + ""), 150);
|
||||
// for (int i = 0; i < header.size(); i++) {
|
||||
// minecraft.fontRenderer.drawString(header.get(i), 0, 17 + i * (minecraft.fontRenderer.FONT_HEIGHT + 1), 0, false);
|
||||
// }
|
||||
//
|
||||
// int maxLines = 4;
|
||||
// IBookletChapter chapter = this.thePage.getChapter();
|
||||
// String aText = chapter.getAllPages()[0].getInfoText();
|
||||
// List<String> text = minecraft.fontRenderer.listFormattedStringToWidth(aText != null ? aText : TextFormatting.DARK_RED + StringUtil.localize("container.nei." + ActuallyAdditions.MODID + ".booklet.noText"), 150);
|
||||
// for (int i = 0; i < Math.min(maxLines, text.size()); i++) {
|
||||
// minecraft.fontRenderer.drawString(text.get(i) + (i == maxLines - 1 && text.size() > maxLines ? TextFormatting.RESET + "" + TextFormatting.BLACK + "..." : ""), 0, 16 + 25 + i * (minecraft.fontRenderer.FONT_HEIGHT + 1), 0, false);
|
||||
// }
|
||||
// minecraft.fontRenderer.drawString(TextFormatting.ITALIC + chapter.getLocalizedName(), 25, 85, 0, false);
|
||||
// minecraft.fontRenderer.drawString(TextFormatting.ITALIC + "Page " + (chapter.getPageIndex(this.thePage) + 1), 25, 95, 0, false);
|
||||
//
|
||||
// super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getButtonX() {
|
||||
// return 0;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getButtonY() {
|
||||
// return 84;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public IBookletPage getPage() {
|
||||
// return this.thePage;
|
||||
// }
|
||||
//}
|
||||
|
|
|
@ -1,69 +1,69 @@
|
|||
/*
|
||||
* This file ("CoffeeMachineRecipeCategory.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2017 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.jei.coffee;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoffeeMachine;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.gui.IDrawable;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.IRecipeCategory;
|
||||
|
||||
public class CoffeeMachineRecipeCategory implements IRecipeCategory<CoffeeMachineRecipeWrapper> {
|
||||
|
||||
public static final String NAME = "actuallyadditions.coffee";
|
||||
|
||||
private final IDrawable background;
|
||||
|
||||
public CoffeeMachineRecipeCategory(IGuiHelper helper) {
|
||||
this.background = helper.createDrawable(AssetUtil.getGuiLocation("gui_nei_coffee_machine"), 0, 0, 126, 92);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUid() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return StringUtil.localize("container.nei." + NAME + ".name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModName() {
|
||||
return ActuallyAdditions.NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return this.background;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout recipeLayout, CoffeeMachineRecipeWrapper wrapper, IIngredients ingredients) {
|
||||
recipeLayout.getItemStacks().init(0, true, 89, 20);
|
||||
recipeLayout.getItemStacks().set(0, Arrays.asList(wrapper.ingredient.getInput().getMatchingStacks()));
|
||||
|
||||
recipeLayout.getItemStacks().init(1, true, 44, 38);
|
||||
recipeLayout.getItemStacks().set(1, wrapper.cup);
|
||||
|
||||
recipeLayout.getItemStacks().init(2, true, 1, 38);
|
||||
recipeLayout.getItemStacks().set(2, Arrays.asList(TileEntityCoffeeMachine.COFFEE.getMatchingStacks()));
|
||||
|
||||
recipeLayout.getItemStacks().init(3, false, 44, 69);
|
||||
recipeLayout.getItemStacks().set(3, wrapper.theOutput);
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * This file ("CoffeeMachineRecipeCategory.java") is part of the Actually Additions mod for Minecraft.
|
||||
// * It is created and owned by Ellpeck and distributed
|
||||
// * under the Actually Additions License to be found at
|
||||
// * http://ellpeck.de/actaddlicense
|
||||
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
// *
|
||||
// * © 2015-2017 Ellpeck
|
||||
// */
|
||||
//
|
||||
//package de.ellpeck.actuallyadditions.mod.jei.coffee;
|
||||
//
|
||||
//import java.util.Arrays;
|
||||
//
|
||||
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
//import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoffeeMachine;
|
||||
//import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
//import mezz.jei.api.IGuiHelper;
|
||||
//import mezz.jei.api.gui.IDrawable;
|
||||
//import mezz.jei.api.gui.IRecipeLayout;
|
||||
//import mezz.jei.api.ingredients.IIngredients;
|
||||
//import mezz.jei.api.recipe.IRecipeCategory;
|
||||
//
|
||||
//public class CoffeeMachineRecipeCategory implements IRecipeCategory<CoffeeMachineRecipeWrapper> {
|
||||
//
|
||||
// public static final String NAME = "actuallyadditions.coffee";
|
||||
//
|
||||
// private final IDrawable background;
|
||||
//
|
||||
// public CoffeeMachineRecipeCategory(IGuiHelper helper) {
|
||||
// this.background = helper.createDrawable(AssetUtil.getGuiLocation("gui_nei_coffee_machine"), 0, 0, 126, 92);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getUid() {
|
||||
// return NAME;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getTitle() {
|
||||
// return StringUtil.localize("container.nei." + NAME + ".name");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getModName() {
|
||||
// return ActuallyAdditions.NAME;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public IDrawable getBackground() {
|
||||
// return this.background;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void setRecipe(IRecipeLayout recipeLayout, CoffeeMachineRecipeWrapper wrapper, IIngredients ingredients) {
|
||||
// recipeLayout.getItemStacks().init(0, true, 89, 20);
|
||||
// recipeLayout.getItemStacks().set(0, Arrays.asList(wrapper.ingredient.getInput().getMatchingStacks()));
|
||||
//
|
||||
// recipeLayout.getItemStacks().init(1, true, 44, 38);
|
||||
// recipeLayout.getItemStacks().set(1, wrapper.cup);
|
||||
//
|
||||
// recipeLayout.getItemStacks().init(2, true, 1, 38);
|
||||
// recipeLayout.getItemStacks().set(2, Arrays.asList(TileEntityCoffeeMachine.COFFEE.getMatchingStacks()));
|
||||
//
|
||||
// recipeLayout.getItemStacks().init(3, false, 44, 69);
|
||||
// recipeLayout.getItemStacks().set(3, wrapper.theOutput);
|
||||
// }
|
||||
//}
|
||||
|
|
|
@ -1,88 +1,88 @@
|
|||
/*
|
||||
* This file ("CoffeeMachineRecipeWrapper.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2017 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.jei.coffee;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
|
||||
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
||||
import de.ellpeck.actuallyadditions.mod.jei.RecipeWrapperWithButton;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoffeeMachine;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.ingredients.VanillaTypes;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CoffeeMachineRecipeWrapper extends RecipeWrapperWithButton {
|
||||
|
||||
public final CoffeeIngredient ingredient;
|
||||
public final ItemStack theOutput;
|
||||
public final ItemStack cup = new ItemStack(ActuallyItems.itemCoffeeCup.get());
|
||||
|
||||
public CoffeeMachineRecipeWrapper(CoffeeIngredient ingredient) {
|
||||
this.ingredient = ingredient;
|
||||
|
||||
this.theOutput = new ItemStack(ActuallyItems.itemCoffee);
|
||||
ActuallyAdditionsAPI.methodHandler.addEffectToStack(this.theOutput, this.ingredient);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getIngredients(IIngredients ingredients) {
|
||||
List<ItemStack> list = new ArrayList<>();
|
||||
for (ItemStack s : this.ingredient.getInput().getMatchingStacks()) {
|
||||
list.add(s);
|
||||
}
|
||||
list.add(this.cup);
|
||||
for (ItemStack s : TileEntityCoffeeMachine.COFFEE.getMatchingStacks()) {
|
||||
list.add(s);
|
||||
}
|
||||
ingredients.setInputs(VanillaTypes.ITEM, list);
|
||||
|
||||
ingredients.setOutput(VanillaTypes.ITEM, this.theOutput);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
|
||||
if (!Strings.isNullOrEmpty(this.ingredient.getExtraText())) {
|
||||
minecraft.fontRenderer.drawString(StringUtil.localize("container.nei." + ActuallyAdditions.MODID + ".coffee.special") + ":", 2, 4, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
|
||||
minecraft.fontRenderer.drawString(this.ingredient.getExtraText(), 2, 16, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
|
||||
}
|
||||
|
||||
if (this.ingredient.getMaxAmplifier() > 0) {
|
||||
minecraft.fontRenderer.drawString(StringUtil.localize("container.nei." + ActuallyAdditions.MODID + ".coffee.maxAmount") + ": " + this.ingredient.getMaxAmplifier(), 2, 28, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
|
||||
}
|
||||
|
||||
super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getButtonX() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getButtonY() {
|
||||
return 68;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBookletPage getPage() {
|
||||
return BookletUtils.findFirstPageForStack(new ItemStack(ActuallyBlocks.blockCoffeeMachine));
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * This file ("CoffeeMachineRecipeWrapper.java") is part of the Actually Additions mod for Minecraft.
|
||||
// * It is created and owned by Ellpeck and distributed
|
||||
// * under the Actually Additions License to be found at
|
||||
// * http://ellpeck.de/actaddlicense
|
||||
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
// *
|
||||
// * © 2015-2017 Ellpeck
|
||||
// */
|
||||
//
|
||||
//package de.ellpeck.actuallyadditions.mod.jei.coffee;
|
||||
//
|
||||
//import com.google.common.base.Strings;
|
||||
//import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
//import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
||||
//import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient;
|
||||
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
//import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||
//import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
|
||||
//import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
||||
//import de.ellpeck.actuallyadditions.mod.jei.RecipeWrapperWithButton;
|
||||
//import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoffeeMachine;
|
||||
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
//import mezz.jei.api.ingredients.IIngredients;
|
||||
//import mezz.jei.api.ingredients.VanillaTypes;
|
||||
//import net.minecraft.client.Minecraft;
|
||||
//import net.minecraft.item.ItemStack;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.List;
|
||||
//
|
||||
//public class CoffeeMachineRecipeWrapper extends RecipeWrapperWithButton {
|
||||
//
|
||||
// public final CoffeeIngredient ingredient;
|
||||
// public final ItemStack theOutput;
|
||||
// public final ItemStack cup = new ItemStack(ActuallyItems.itemCoffeeCup.get());
|
||||
//
|
||||
// public CoffeeMachineRecipeWrapper(CoffeeIngredient ingredient) {
|
||||
// this.ingredient = ingredient;
|
||||
//
|
||||
// this.theOutput = new ItemStack(ActuallyItems.itemCoffee);
|
||||
// ActuallyAdditionsAPI.methodHandler.addEffectToStack(this.theOutput, this.ingredient);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void getIngredients(IIngredients ingredients) {
|
||||
// List<ItemStack> list = new ArrayList<>();
|
||||
// for (ItemStack s : this.ingredient.getInput().getMatchingStacks()) {
|
||||
// list.add(s);
|
||||
// }
|
||||
// list.add(this.cup);
|
||||
// for (ItemStack s : TileEntityCoffeeMachine.COFFEE.getMatchingStacks()) {
|
||||
// list.add(s);
|
||||
// }
|
||||
// ingredients.setInputs(VanillaTypes.ITEM, list);
|
||||
//
|
||||
// ingredients.setOutput(VanillaTypes.ITEM, this.theOutput);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
|
||||
// if (!Strings.isNullOrEmpty(this.ingredient.getExtraText())) {
|
||||
// minecraft.fontRenderer.drawString(StringUtil.localize("container.nei." + ActuallyAdditions.MODID + ".coffee.special") + ":", 2, 4, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
|
||||
// minecraft.fontRenderer.drawString(this.ingredient.getExtraText(), 2, 16, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
|
||||
// }
|
||||
//
|
||||
// if (this.ingredient.getMaxAmplifier() > 0) {
|
||||
// minecraft.fontRenderer.drawString(StringUtil.localize("container.nei." + ActuallyAdditions.MODID + ".coffee.maxAmount") + ": " + this.ingredient.getMaxAmplifier(), 2, 28, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
|
||||
// }
|
||||
//
|
||||
// super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getButtonX() {
|
||||
// return 0;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getButtonY() {
|
||||
// return 68;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public IBookletPage getPage() {
|
||||
// return BookletUtils.findFirstPageForStack(new ItemStack(ActuallyBlocks.blockCoffeeMachine));
|
||||
// }
|
||||
//}
|
||||
|
|
|
@ -1,68 +1,68 @@
|
|||
/*
|
||||
* This file ("CrusherRecipeCategory.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2017 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.jei.crusher;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.gui.IDrawable;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.IRecipeCategory;
|
||||
|
||||
public class CrusherRecipeCategory implements IRecipeCategory<CrusherRecipeWrapper> {
|
||||
|
||||
public static final String NAME = "actuallyadditions.crushing";
|
||||
|
||||
private final IDrawable background;
|
||||
|
||||
public CrusherRecipeCategory(IGuiHelper helper) {
|
||||
this.background = helper.createDrawable(AssetUtil.getGuiLocation("gui_grinder"), 60, 13, 56, 79);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUid() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return StringUtil.localize("container.nei." + NAME + ".name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModName() {
|
||||
return ActuallyAdditions.NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return this.background;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout recipeLayout, CrusherRecipeWrapper wrapper, IIngredients ingredients) {
|
||||
recipeLayout.getItemStacks().init(0, true, 19, 7);
|
||||
recipeLayout.getItemStacks().set(0, Arrays.asList(wrapper.theRecipe.getInput().getMatchingStacks()));
|
||||
|
||||
recipeLayout.getItemStacks().init(1, false, 7, 55);
|
||||
recipeLayout.getItemStacks().set(1, wrapper.theRecipe.getOutputOne());
|
||||
|
||||
if (StackUtil.isValid(wrapper.theRecipe.getOutputTwo())) {
|
||||
recipeLayout.getItemStacks().init(2, false, 31, 55);
|
||||
recipeLayout.getItemStacks().set(2, wrapper.theRecipe.getOutputTwo());
|
||||
}
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * This file ("CrusherRecipeCategory.java") is part of the Actually Additions mod for Minecraft.
|
||||
// * It is created and owned by Ellpeck and distributed
|
||||
// * under the Actually Additions License to be found at
|
||||
// * http://ellpeck.de/actaddlicense
|
||||
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
// *
|
||||
// * © 2015-2017 Ellpeck
|
||||
// */
|
||||
//
|
||||
//package de.ellpeck.actuallyadditions.mod.jei.crusher;
|
||||
//
|
||||
//import java.util.Arrays;
|
||||
//
|
||||
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
//import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
//import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
//import mezz.jei.api.IGuiHelper;
|
||||
//import mezz.jei.api.gui.IDrawable;
|
||||
//import mezz.jei.api.gui.IRecipeLayout;
|
||||
//import mezz.jei.api.ingredients.IIngredients;
|
||||
//import mezz.jei.api.recipe.IRecipeCategory;
|
||||
//
|
||||
//public class CrusherRecipeCategory implements IRecipeCategory<CrusherRecipeWrapper> {
|
||||
//
|
||||
// public static final String NAME = "actuallyadditions.crushing";
|
||||
//
|
||||
// private final IDrawable background;
|
||||
//
|
||||
// public CrusherRecipeCategory(IGuiHelper helper) {
|
||||
// this.background = helper.createDrawable(AssetUtil.getGuiLocation("gui_grinder"), 60, 13, 56, 79);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getUid() {
|
||||
// return NAME;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getTitle() {
|
||||
// return StringUtil.localize("container.nei." + NAME + ".name");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getModName() {
|
||||
// return ActuallyAdditions.NAME;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public IDrawable getBackground() {
|
||||
// return this.background;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void setRecipe(IRecipeLayout recipeLayout, CrusherRecipeWrapper wrapper, IIngredients ingredients) {
|
||||
// recipeLayout.getItemStacks().init(0, true, 19, 7);
|
||||
// recipeLayout.getItemStacks().set(0, Arrays.asList(wrapper.theRecipe.getInput().getMatchingStacks()));
|
||||
//
|
||||
// recipeLayout.getItemStacks().init(1, false, 7, 55);
|
||||
// recipeLayout.getItemStacks().set(1, wrapper.theRecipe.getOutputOne());
|
||||
//
|
||||
// if (StackUtil.isValid(wrapper.theRecipe.getOutputTwo())) {
|
||||
// recipeLayout.getItemStacks().init(2, false, 31, 55);
|
||||
// recipeLayout.getItemStacks().set(2, wrapper.theRecipe.getOutputTwo());
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
|
|
@ -1,72 +1,72 @@
|
|||
/*
|
||||
* This file ("CrusherRecipeWrapper.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2017 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.jei.crusher;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
|
||||
import de.ellpeck.actuallyadditions.mod.jei.RecipeWrapperWithButton;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.ingredients.VanillaTypes;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class CrusherRecipeWrapper extends RecipeWrapperWithButton {
|
||||
|
||||
public final CrusherRecipe theRecipe;
|
||||
|
||||
public CrusherRecipeWrapper(CrusherRecipe recipe) {
|
||||
this.theRecipe = recipe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getIngredients(IIngredients ingredients) {
|
||||
ingredients.setInputs(VanillaTypes.ITEM, Arrays.asList(this.theRecipe.getInput().getMatchingStacks()));
|
||||
|
||||
List<ItemStack> list = new ArrayList<>();
|
||||
list.add(this.theRecipe.getOutputOne());
|
||||
if (StackUtil.isValid(this.theRecipe.getOutputTwo())) {
|
||||
list.add(this.theRecipe.getOutputTwo());
|
||||
}
|
||||
ingredients.setOutputs(VanillaTypes.ITEM, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
|
||||
if (StackUtil.isValid(this.theRecipe.getOutputTwo())) {
|
||||
minecraft.fontRenderer.drawString(this.theRecipe.getSecondChance() + "%", 60, 60, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
|
||||
}
|
||||
|
||||
super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getButtonX() {
|
||||
return -5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getButtonY() {
|
||||
return 26;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBookletPage getPage() {
|
||||
return BookletUtils.findFirstPageForStack(new ItemStack(ActuallyBlocks.blockGrinder));
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * This file ("CrusherRecipeWrapper.java") is part of the Actually Additions mod for Minecraft.
|
||||
// * It is created and owned by Ellpeck and distributed
|
||||
// * under the Actually Additions License to be found at
|
||||
// * http://ellpeck.de/actaddlicense
|
||||
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
// *
|
||||
// * © 2015-2017 Ellpeck
|
||||
// */
|
||||
//
|
||||
//package de.ellpeck.actuallyadditions.mod.jei.crusher;
|
||||
//
|
||||
//import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
||||
//import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
|
||||
//import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||
//import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
|
||||
//import de.ellpeck.actuallyadditions.mod.jei.RecipeWrapperWithButton;
|
||||
//import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
//import mezz.jei.api.ingredients.IIngredients;
|
||||
//import mezz.jei.api.ingredients.VanillaTypes;
|
||||
//import net.minecraft.client.Minecraft;
|
||||
//import net.minecraft.item.ItemStack;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.Arrays;
|
||||
//import java.util.List;
|
||||
//
|
||||
//public class CrusherRecipeWrapper extends RecipeWrapperWithButton {
|
||||
//
|
||||
// public final CrusherRecipe theRecipe;
|
||||
//
|
||||
// public CrusherRecipeWrapper(CrusherRecipe recipe) {
|
||||
// this.theRecipe = recipe;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void getIngredients(IIngredients ingredients) {
|
||||
// ingredients.setInputs(VanillaTypes.ITEM, Arrays.asList(this.theRecipe.getInput().getMatchingStacks()));
|
||||
//
|
||||
// List<ItemStack> list = new ArrayList<>();
|
||||
// list.add(this.theRecipe.getOutputOne());
|
||||
// if (StackUtil.isValid(this.theRecipe.getOutputTwo())) {
|
||||
// list.add(this.theRecipe.getOutputTwo());
|
||||
// }
|
||||
// ingredients.setOutputs(VanillaTypes.ITEM, list);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
|
||||
// if (StackUtil.isValid(this.theRecipe.getOutputTwo())) {
|
||||
// minecraft.fontRenderer.drawString(this.theRecipe.getSecondChance() + "%", 60, 60, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
|
||||
// }
|
||||
//
|
||||
// super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getButtonX() {
|
||||
// return -5;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getButtonY() {
|
||||
// return 26;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public IBookletPage getPage() {
|
||||
// return BookletUtils.findFirstPageForStack(new ItemStack(ActuallyBlocks.blockGrinder));
|
||||
// }
|
||||
//}
|
||||
|
|
|
@ -1,74 +1,74 @@
|
|||
/*
|
||||
* This file ("EmpowererRecipeCategory.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2017 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.jei.empowerer;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.gui.IDrawable;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.IRecipeCategory;
|
||||
|
||||
public class EmpowererRecipeCategory implements IRecipeCategory<EmpowererRecipeWrapper> {
|
||||
|
||||
public static final String NAME = "actuallyadditions.empowerer";
|
||||
|
||||
private final IDrawable background;
|
||||
|
||||
public EmpowererRecipeCategory(IGuiHelper helper) {
|
||||
this.background = helper.createDrawable(AssetUtil.getGuiLocation("gui_nei_empowerer"), 0, 0, 135, 80);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUid() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return StringUtil.localize("container.nei." + NAME + ".name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModName() {
|
||||
return ActuallyAdditions.NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return this.background;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout recipeLayout, EmpowererRecipeWrapper wrapper, IIngredients ingredients) {
|
||||
recipeLayout.getItemStacks().init(0, true, 31, 31);
|
||||
recipeLayout.getItemStacks().set(0, Arrays.asList(wrapper.theRecipe.getInput().getMatchingStacks()));
|
||||
|
||||
recipeLayout.getItemStacks().init(1, true, 1, 31);
|
||||
recipeLayout.getItemStacks().set(1, Arrays.asList(wrapper.theRecipe.getStandOne().getMatchingStacks()));
|
||||
|
||||
recipeLayout.getItemStacks().init(2, true, 31, 1);
|
||||
recipeLayout.getItemStacks().set(2, Arrays.asList(wrapper.theRecipe.getStandTwo().getMatchingStacks()));
|
||||
|
||||
recipeLayout.getItemStacks().init(3, true, 61, 31);
|
||||
recipeLayout.getItemStacks().set(3, Arrays.asList(wrapper.theRecipe.getStandThree().getMatchingStacks()));
|
||||
|
||||
recipeLayout.getItemStacks().init(4, true, 31, 61);
|
||||
recipeLayout.getItemStacks().set(4, Arrays.asList(wrapper.theRecipe.getStandFour().getMatchingStacks()));
|
||||
|
||||
recipeLayout.getItemStacks().init(5, false, 112, 31);
|
||||
recipeLayout.getItemStacks().set(5, wrapper.theRecipe.getOutput());
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * This file ("EmpowererRecipeCategory.java") is part of the Actually Additions mod for Minecraft.
|
||||
// * It is created and owned by Ellpeck and distributed
|
||||
// * under the Actually Additions License to be found at
|
||||
// * http://ellpeck.de/actaddlicense
|
||||
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
// *
|
||||
// * © 2015-2017 Ellpeck
|
||||
// */
|
||||
//
|
||||
//package de.ellpeck.actuallyadditions.mod.jei.empowerer;
|
||||
//
|
||||
//import java.util.Arrays;
|
||||
//
|
||||
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
//import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
//import mezz.jei.api.IGuiHelper;
|
||||
//import mezz.jei.api.gui.IDrawable;
|
||||
//import mezz.jei.api.gui.IRecipeLayout;
|
||||
//import mezz.jei.api.ingredients.IIngredients;
|
||||
//import mezz.jei.api.recipe.IRecipeCategory;
|
||||
//
|
||||
//public class EmpowererRecipeCategory implements IRecipeCategory<EmpowererRecipeWrapper> {
|
||||
//
|
||||
// public static final String NAME = "actuallyadditions.empowerer";
|
||||
//
|
||||
// private final IDrawable background;
|
||||
//
|
||||
// public EmpowererRecipeCategory(IGuiHelper helper) {
|
||||
// this.background = helper.createDrawable(AssetUtil.getGuiLocation("gui_nei_empowerer"), 0, 0, 135, 80);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getUid() {
|
||||
// return NAME;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getTitle() {
|
||||
// return StringUtil.localize("container.nei." + NAME + ".name");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getModName() {
|
||||
// return ActuallyAdditions.NAME;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public IDrawable getBackground() {
|
||||
// return this.background;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void setRecipe(IRecipeLayout recipeLayout, EmpowererRecipeWrapper wrapper, IIngredients ingredients) {
|
||||
// recipeLayout.getItemStacks().init(0, true, 31, 31);
|
||||
// recipeLayout.getItemStacks().set(0, Arrays.asList(wrapper.theRecipe.getInput().getMatchingStacks()));
|
||||
//
|
||||
// recipeLayout.getItemStacks().init(1, true, 1, 31);
|
||||
// recipeLayout.getItemStacks().set(1, Arrays.asList(wrapper.theRecipe.getStandOne().getMatchingStacks()));
|
||||
//
|
||||
// recipeLayout.getItemStacks().init(2, true, 31, 1);
|
||||
// recipeLayout.getItemStacks().set(2, Arrays.asList(wrapper.theRecipe.getStandTwo().getMatchingStacks()));
|
||||
//
|
||||
// recipeLayout.getItemStacks().init(3, true, 61, 31);
|
||||
// recipeLayout.getItemStacks().set(3, Arrays.asList(wrapper.theRecipe.getStandThree().getMatchingStacks()));
|
||||
//
|
||||
// recipeLayout.getItemStacks().init(4, true, 31, 61);
|
||||
// recipeLayout.getItemStacks().set(4, Arrays.asList(wrapper.theRecipe.getStandFour().getMatchingStacks()));
|
||||
//
|
||||
// recipeLayout.getItemStacks().init(5, false, 112, 31);
|
||||
// recipeLayout.getItemStacks().set(5, wrapper.theRecipe.getOutput());
|
||||
// }
|
||||
//}
|
||||
|
|
|
@ -1,70 +1,70 @@
|
|||
/*
|
||||
* This file ("EmpowererRecipeWrapper.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2017 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.jei.empowerer;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
|
||||
import de.ellpeck.actuallyadditions.mod.jei.RecipeWrapperWithButton;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.ingredients.VanillaTypes;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class EmpowererRecipeWrapper extends RecipeWrapperWithButton {
|
||||
|
||||
public final EmpowererRecipe theRecipe;
|
||||
|
||||
public EmpowererRecipeWrapper(EmpowererRecipe recipe) {
|
||||
this.theRecipe = recipe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getIngredients(IIngredients ingredients) {
|
||||
List<ItemStack> inputs = new ArrayList<>();
|
||||
for (ItemStack s : this.theRecipe.getInput().getMatchingStacks()) {
|
||||
inputs.add(s);
|
||||
}
|
||||
for (ItemStack s : this.theRecipe.getStandOne().getMatchingStacks()) {
|
||||
inputs.add(s);
|
||||
}
|
||||
for (ItemStack s : this.theRecipe.getStandTwo().getMatchingStacks()) {
|
||||
inputs.add(s);
|
||||
}
|
||||
for (ItemStack s : this.theRecipe.getStandThree().getMatchingStacks()) {
|
||||
inputs.add(s);
|
||||
}
|
||||
for (ItemStack s : this.theRecipe.getStandFour().getMatchingStacks()) {
|
||||
inputs.add(s);
|
||||
}
|
||||
|
||||
ingredients.setInputs(VanillaTypes.ITEM, inputs);
|
||||
ingredients.setOutput(VanillaTypes.ITEM, this.theRecipe.getOutput());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getButtonX() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getButtonY() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBookletPage getPage() {
|
||||
return BookletUtils.findFirstPageForStack(new ItemStack(ActuallyBlocks.blockEmpowerer));
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * This file ("EmpowererRecipeWrapper.java") is part of the Actually Additions mod for Minecraft.
|
||||
// * It is created and owned by Ellpeck and distributed
|
||||
// * under the Actually Additions License to be found at
|
||||
// * http://ellpeck.de/actaddlicense
|
||||
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
// *
|
||||
// * © 2015-2017 Ellpeck
|
||||
// */
|
||||
//
|
||||
//package de.ellpeck.actuallyadditions.mod.jei.empowerer;
|
||||
//
|
||||
//import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
||||
//import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe;
|
||||
//import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||
//import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
|
||||
//import de.ellpeck.actuallyadditions.mod.jei.RecipeWrapperWithButton;
|
||||
//import mezz.jei.api.ingredients.IIngredients;
|
||||
//import mezz.jei.api.ingredients.VanillaTypes;
|
||||
//import net.minecraft.item.ItemStack;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.List;
|
||||
//
|
||||
//public class EmpowererRecipeWrapper extends RecipeWrapperWithButton {
|
||||
//
|
||||
// public final EmpowererRecipe theRecipe;
|
||||
//
|
||||
// public EmpowererRecipeWrapper(EmpowererRecipe recipe) {
|
||||
// this.theRecipe = recipe;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void getIngredients(IIngredients ingredients) {
|
||||
// List<ItemStack> inputs = new ArrayList<>();
|
||||
// for (ItemStack s : this.theRecipe.getInput().getMatchingStacks()) {
|
||||
// inputs.add(s);
|
||||
// }
|
||||
// for (ItemStack s : this.theRecipe.getStandOne().getMatchingStacks()) {
|
||||
// inputs.add(s);
|
||||
// }
|
||||
// for (ItemStack s : this.theRecipe.getStandTwo().getMatchingStacks()) {
|
||||
// inputs.add(s);
|
||||
// }
|
||||
// for (ItemStack s : this.theRecipe.getStandThree().getMatchingStacks()) {
|
||||
// inputs.add(s);
|
||||
// }
|
||||
// for (ItemStack s : this.theRecipe.getStandFour().getMatchingStacks()) {
|
||||
// inputs.add(s);
|
||||
// }
|
||||
//
|
||||
// ingredients.setInputs(VanillaTypes.ITEM, inputs);
|
||||
// ingredients.setOutput(VanillaTypes.ITEM, this.theRecipe.getOutput());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getButtonX() {
|
||||
// return 2;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getButtonY() {
|
||||
// return 2;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public IBookletPage getPage() {
|
||||
// return BookletUtils.findFirstPageForStack(new ItemStack(ActuallyBlocks.blockEmpowerer));
|
||||
// }
|
||||
//}
|
||||
|
|
|
@ -1,69 +1,69 @@
|
|||
/*
|
||||
* This file ("ReconstructorRecipeCategory.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2017 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.jei.reconstructor;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.gui.IDrawable;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.ingredients.VanillaTypes;
|
||||
import mezz.jei.api.recipe.IRecipeCategory;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ReconstructorRecipeCategory implements IRecipeCategory<ReconstructorRecipeWrapper> {
|
||||
|
||||
public static final String NAME = "actuallyadditions.reconstructor";
|
||||
|
||||
private static final ItemStack RECONSTRUCTOR = new ItemStack(ActuallyBlocks.blockAtomicReconstructor);
|
||||
private final IDrawable background;
|
||||
|
||||
public ReconstructorRecipeCategory(IGuiHelper helper) {
|
||||
this.background = helper.createDrawable(AssetUtil.getGuiLocation("gui_nei_atomic_reconstructor"), 0, 0, 96, 60);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUid() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return StringUtil.localize("container.nei." + NAME + ".name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModName() {
|
||||
return ActuallyAdditions.NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return this.background;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(Minecraft minecraft) {
|
||||
AssetUtil.renderStackToGui(RECONSTRUCTOR, 34, 19, 1.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout recipeLayout, ReconstructorRecipeWrapper wrapper, IIngredients ingredients) {
|
||||
recipeLayout.getItemStacks().init(0, true, 4, 18);
|
||||
recipeLayout.getItemStacks().set(0, ingredients.getInputs(VanillaTypes.ITEM).get(0).get(0));
|
||||
recipeLayout.getItemStacks().init(1, false, 66, 18);
|
||||
recipeLayout.getItemStacks().set(1, ingredients.getOutputs(VanillaTypes.ITEM).get(0).get(0));
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * This file ("ReconstructorRecipeCategory.java") is part of the Actually Additions mod for Minecraft.
|
||||
// * It is created and owned by Ellpeck and distributed
|
||||
// * under the Actually Additions License to be found at
|
||||
// * http://ellpeck.de/actaddlicense
|
||||
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
// *
|
||||
// * © 2015-2017 Ellpeck
|
||||
// */
|
||||
//
|
||||
//package de.ellpeck.actuallyadditions.mod.jei.reconstructor;
|
||||
//
|
||||
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
//import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||
//import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
//import mezz.jei.api.IGuiHelper;
|
||||
//import mezz.jei.api.gui.IDrawable;
|
||||
//import mezz.jei.api.gui.IRecipeLayout;
|
||||
//import mezz.jei.api.ingredients.IIngredients;
|
||||
//import mezz.jei.api.ingredients.VanillaTypes;
|
||||
//import mezz.jei.api.recipe.IRecipeCategory;
|
||||
//import net.minecraft.client.Minecraft;
|
||||
//import net.minecraft.item.ItemStack;
|
||||
//
|
||||
//public class ReconstructorRecipeCategory implements IRecipeCategory<ReconstructorRecipeWrapper> {
|
||||
//
|
||||
// public static final String NAME = "actuallyadditions.reconstructor";
|
||||
//
|
||||
// private static final ItemStack RECONSTRUCTOR = new ItemStack(ActuallyBlocks.blockAtomicReconstructor);
|
||||
// private final IDrawable background;
|
||||
//
|
||||
// public ReconstructorRecipeCategory(IGuiHelper helper) {
|
||||
// this.background = helper.createDrawable(AssetUtil.getGuiLocation("gui_nei_atomic_reconstructor"), 0, 0, 96, 60);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getUid() {
|
||||
// return NAME;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getTitle() {
|
||||
// return StringUtil.localize("container.nei." + NAME + ".name");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getModName() {
|
||||
// return ActuallyAdditions.NAME;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public IDrawable getBackground() {
|
||||
// return this.background;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void drawExtras(Minecraft minecraft) {
|
||||
// AssetUtil.renderStackToGui(RECONSTRUCTOR, 34, 19, 1.0F);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void setRecipe(IRecipeLayout recipeLayout, ReconstructorRecipeWrapper wrapper, IIngredients ingredients) {
|
||||
// recipeLayout.getItemStacks().init(0, true, 4, 18);
|
||||
// recipeLayout.getItemStacks().set(0, ingredients.getInputs(VanillaTypes.ITEM).get(0).get(0));
|
||||
// recipeLayout.getItemStacks().init(1, false, 66, 18);
|
||||
// recipeLayout.getItemStacks().set(1, ingredients.getOutputs(VanillaTypes.ITEM).get(0).get(0));
|
||||
// }
|
||||
//}
|
||||
|
|
|
@ -1,98 +1,98 @@
|
|||
/*
|
||||
* This file ("ReconstructorRecipeWrapper.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2017 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.jei.reconstructor;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
|
||||
import de.ellpeck.actuallyadditions.mod.jei.RecipeWrapperWithButton;
|
||||
import de.ellpeck.actuallyadditions.mod.recipe.EnchBookConversion;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.ingredients.VanillaTypes;
|
||||
import mezz.jei.api.recipe.IRecipeWrapperFactory;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ReconstructorRecipeWrapper extends RecipeWrapperWithButton {
|
||||
|
||||
public static final IRecipeWrapperFactory<LensConversionRecipe> FACTORY = (recipe) -> {
|
||||
if (recipe instanceof EnchBookConversion) {
|
||||
return new EnchBookWrapper((EnchBookConversion) recipe);
|
||||
}
|
||||
return new ReconstructorRecipeWrapper(recipe);
|
||||
};
|
||||
|
||||
public final LensConversionRecipe theRecipe;
|
||||
|
||||
public ReconstructorRecipeWrapper(LensConversionRecipe recipe) {
|
||||
this.theRecipe = recipe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getIngredients(IIngredients ingredients) {
|
||||
ingredients.setInputs(VanillaTypes.ITEM, Arrays.asList(this.theRecipe.getInput().getMatchingStacks()));
|
||||
ingredients.setOutput(VanillaTypes.ITEM, this.theRecipe.getOutput());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
|
||||
minecraft.fontRenderer.drawString(this.theRecipe.getEnergyUsed() + " " + I18n.format("actuallyadditions.cf"), 55, 0, 0xFFFFFF, true);
|
||||
super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getButtonX() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getButtonY() {
|
||||
return 40;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBookletPage getPage() {
|
||||
return BookletUtils.findFirstPageForStack(new ItemStack(ActuallyBlocks.blockAtomicReconstructor));
|
||||
}
|
||||
|
||||
public static class EnchBookWrapper extends ReconstructorRecipeWrapper {
|
||||
|
||||
private static final ItemStack BOOK = new ItemStack(Items.ENCHANTED_BOOK);
|
||||
private static final ItemStack OUT = new ItemStack(Items.ENCHANTED_BOOK);
|
||||
|
||||
static {
|
||||
OUT.setStackDisplayName("Split Book");
|
||||
CompoundNBT t = OUT.getTagCompound().getCompoundTag("display");
|
||||
ListNBT l = new ListNBT();
|
||||
l.appendTag(new NBTTagString("Book will be split based on enchantments!"));
|
||||
t.setTag("Lore", l);
|
||||
}
|
||||
|
||||
public EnchBookWrapper(EnchBookConversion recipe) {
|
||||
super(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getIngredients(IIngredients ingredients) {
|
||||
ingredients.setInput(VanillaTypes.ITEM, BOOK);
|
||||
ingredients.setOutput(VanillaTypes.ITEM, OUT);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * This file ("ReconstructorRecipeWrapper.java") is part of the Actually Additions mod for Minecraft.
|
||||
// * It is created and owned by Ellpeck and distributed
|
||||
// * under the Actually Additions License to be found at
|
||||
// * http://ellpeck.de/actaddlicense
|
||||
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
// *
|
||||
// * © 2015-2017 Ellpeck
|
||||
// */
|
||||
//
|
||||
//package de.ellpeck.actuallyadditions.mod.jei.reconstructor;
|
||||
//
|
||||
//import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
||||
//import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
|
||||
//import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||
//import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
|
||||
//import de.ellpeck.actuallyadditions.mod.jei.RecipeWrapperWithButton;
|
||||
//import de.ellpeck.actuallyadditions.mod.recipe.EnchBookConversion;
|
||||
//import mezz.jei.api.ingredients.IIngredients;
|
||||
//import mezz.jei.api.ingredients.VanillaTypes;
|
||||
//import mezz.jei.api.recipe.IRecipeWrapperFactory;
|
||||
//import net.minecraft.client.Minecraft;
|
||||
//import net.minecraft.client.resources.I18n;
|
||||
//import net.minecraft.init.Items;
|
||||
//import net.minecraft.item.ItemStack;
|
||||
//import net.minecraft.nbt.CompoundNBT;
|
||||
//import net.minecraft.nbt.ListNBT;
|
||||
//import net.minecraft.nbt.NBTTagString;
|
||||
//
|
||||
//import java.util.Arrays;
|
||||
//
|
||||
//public class ReconstructorRecipeWrapper extends RecipeWrapperWithButton {
|
||||
//
|
||||
// public static final IRecipeWrapperFactory<LensConversionRecipe> FACTORY = (recipe) -> {
|
||||
// if (recipe instanceof EnchBookConversion) {
|
||||
// return new EnchBookWrapper((EnchBookConversion) recipe);
|
||||
// }
|
||||
// return new ReconstructorRecipeWrapper(recipe);
|
||||
// };
|
||||
//
|
||||
// public final LensConversionRecipe theRecipe;
|
||||
//
|
||||
// public ReconstructorRecipeWrapper(LensConversionRecipe recipe) {
|
||||
// this.theRecipe = recipe;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void getIngredients(IIngredients ingredients) {
|
||||
// ingredients.setInputs(VanillaTypes.ITEM, Arrays.asList(this.theRecipe.getInput().getMatchingStacks()));
|
||||
// ingredients.setOutput(VanillaTypes.ITEM, this.theRecipe.getOutput());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
|
||||
// minecraft.fontRenderer.drawString(this.theRecipe.getEnergyUsed() + " " + I18n.format("actuallyadditions.cf"), 55, 0, 0xFFFFFF, true);
|
||||
// super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getButtonX() {
|
||||
// return 3;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getButtonY() {
|
||||
// return 40;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public IBookletPage getPage() {
|
||||
// return BookletUtils.findFirstPageForStack(new ItemStack(ActuallyBlocks.blockAtomicReconstructor));
|
||||
// }
|
||||
//
|
||||
// public static class EnchBookWrapper extends ReconstructorRecipeWrapper {
|
||||
//
|
||||
// private static final ItemStack BOOK = new ItemStack(Items.ENCHANTED_BOOK);
|
||||
// private static final ItemStack OUT = new ItemStack(Items.ENCHANTED_BOOK);
|
||||
//
|
||||
// static {
|
||||
// OUT.setStackDisplayName("Split Book");
|
||||
// CompoundNBT t = OUT.getTagCompound().getCompoundTag("display");
|
||||
// ListNBT l = new ListNBT();
|
||||
// l.appendTag(new NBTTagString("Book will be split based on enchantments!"));
|
||||
// t.setTag("Lore", l);
|
||||
// }
|
||||
//
|
||||
// public EnchBookWrapper(EnchBookConversion recipe) {
|
||||
// super(recipe);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void getIngredients(IIngredients ingredients) {
|
||||
// ingredients.setInput(VanillaTypes.ITEM, BOOK);
|
||||
// ingredients.setOutput(VanillaTypes.ITEM, OUT);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//}
|
||||
|
|
|
@ -19,7 +19,7 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
|||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
|
||||
public class PacketClientToServer implements IMessage {
|
||||
public class PacketClientToServer {
|
||||
|
||||
private CompoundNBT data;
|
||||
private IDataHandler handler;
|
||||
|
|
|
@ -21,7 +21,8 @@ import net.minecraft.entity.player.ServerPlayerEntity;
|
|||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
public final class PacketHandlerHelper {
|
||||
|
||||
|
@ -44,7 +45,7 @@ public final class PacketHandlerHelper {
|
|||
|
||||
CompoundNBT data = new CompoundNBT();
|
||||
PlayerData.getDataFromPlayer(player).writeToNBT(data, false);
|
||||
compound.setTag("Data", data);
|
||||
compound.put("Data", data);
|
||||
|
||||
if (player instanceof ServerPlayerEntity) {
|
||||
PacketHandler.THE_NETWORK.sendTo(new PacketServerToClient(compound, PacketHandler.SYNC_PLAYER_DATA), (ServerPlayerEntity) player);
|
||||
|
@ -65,11 +66,11 @@ public final class PacketHandlerHelper {
|
|||
PlayerSave data = PlayerData.getDataFromPlayer(player);
|
||||
|
||||
if (type == 0) {
|
||||
compound.setTag("Bookmarks", data.saveBookmarks());
|
||||
compound.put("Bookmarks", data.saveBookmarks());
|
||||
} else if (type == 1) {
|
||||
compound.putBoolean("DidBookTutorial", data.didBookTutorial);
|
||||
} else if (type == 2) {
|
||||
compound.setTag("Trials", data.saveTrials());
|
||||
compound.put("Trials", data.saveTrials());
|
||||
|
||||
int total = 0;
|
||||
for (IBookletChapter chapter : ActuallyAdditionsAPI.entryTrials.getAllChapters()) {
|
||||
|
@ -96,7 +97,7 @@ public final class PacketHandlerHelper {
|
|||
compound.putInt("WorldID", tile.getWorld().provider.getDimension());
|
||||
compound.putInt("PlayerID", Minecraft.getInstance().player.getEntityId());
|
||||
compound.putInt("NumberID", id);
|
||||
compound.setDouble("Number", number);
|
||||
compound.putDouble("Number", number);
|
||||
PacketHandler.THE_NETWORK.sendToServer(new PacketClientToServer(compound, PacketHandler.GUI_NUMBER_TO_TILE_HANDLER));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,133 +10,120 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.recipe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import net.minecraftforge.oredict.OreIngredient;
|
||||
|
||||
public final class CrusherRecipeRegistry {
|
||||
|
||||
public static final ArrayList<SearchCase> SEARCH_CASES = new ArrayList<>();
|
||||
|
||||
public static void registerFinally() {
|
||||
ArrayList<String> oresNoResult = new ArrayList<>();
|
||||
int recipeStartedAt = ActuallyAdditionsAPI.CRUSHER_RECIPES.size();
|
||||
|
||||
for (String ore : OreDictionary.getOreNames()) {
|
||||
if (!hasException(ore)) {
|
||||
for (SearchCase theCase : SEARCH_CASES) {
|
||||
if (ore.length() > theCase.theCase.length()) {
|
||||
if (ore.substring(0, theCase.theCase.length()).equals(theCase.theCase)) {
|
||||
String outputOre = theCase.resultPreString + ore.substring(theCase.theCase.length());
|
||||
List<ItemStack> outputs = OreDictionary.getOres(outputOre, false);
|
||||
ItemStack output = outputs.isEmpty() ? ItemStack.EMPTY : outputs.get(0).copy();
|
||||
output.setCount(theCase.resultAmount);
|
||||
if (output.isEmpty()) {
|
||||
if (!oresNoResult.contains(ore)) {
|
||||
oresNoResult.add(ore);
|
||||
}
|
||||
} else ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient(ore), output, StackUtil.getEmpty(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<String> addedRecipes = new ArrayList<>();
|
||||
for (int i = recipeStartedAt; i < ActuallyAdditionsAPI.CRUSHER_RECIPES.size(); i++) {
|
||||
CrusherRecipe recipe = ActuallyAdditionsAPI.CRUSHER_RECIPES.get(i);
|
||||
addedRecipes.add(recipe.getInput().getMatchingStacks() + " -> " + recipe.getOutputOne());
|
||||
}
|
||||
ActuallyAdditions.LOGGER.debug("Added " + addedRecipes.size() + " Crusher Recipes automatically: " + addedRecipes);
|
||||
ActuallyAdditions.LOGGER.debug("Couldn't add " + oresNoResult.size() + " Crusher Recipes automatically, either because the inputs were missing outputs, or because they exist already: " + oresNoResult);
|
||||
removeDuplicateRecipes();
|
||||
}
|
||||
|
||||
public static void removeDuplicateRecipes() {
|
||||
ArrayList<CrusherRecipe> usable = new ArrayList<>();
|
||||
ArrayList<CrusherRecipe> removed = new ArrayList<>();
|
||||
for (CrusherRecipe r : ActuallyAdditionsAPI.CRUSHER_RECIPES) {
|
||||
boolean canUse = true;
|
||||
if (r.getInput().getMatchingStacks().length == 0) canUse = false;
|
||||
else for (CrusherRecipe re : usable) {
|
||||
if (re.getInput().apply(r.getInput().getMatchingStacks()[0])) canUse = false;
|
||||
}
|
||||
|
||||
if (canUse) usable.add(r);
|
||||
else removed.add(r);
|
||||
}
|
||||
|
||||
ActuallyAdditionsAPI.CRUSHER_RECIPES.clear();
|
||||
ActuallyAdditionsAPI.CRUSHER_RECIPES.addAll(usable);
|
||||
ActuallyAdditions.LOGGER.debug(String.format("Removed %s crusher recipes that had dupliate inputs, %s remain.", removed.size(), usable.size()));
|
||||
}
|
||||
|
||||
public static boolean hasBlacklistedOutput(ItemStack output, String[] config) {
|
||||
if (StackUtil.isValid(output)) {
|
||||
Item item = output.getItem();
|
||||
if (item != null) {
|
||||
String reg = item.getRegistryName().toString();
|
||||
|
||||
for (String conf : config) {
|
||||
String confReg = conf;
|
||||
int meta = 0;
|
||||
|
||||
if (conf.contains("@")) {
|
||||
try {
|
||||
String[] split = conf.split("@");
|
||||
confReg = split[0];
|
||||
meta = Integer.parseInt(split[1]);
|
||||
} catch (Exception e) {
|
||||
ActuallyAdditions.LOGGER.warn("A config option appears to be incorrect: The entry " + conf + " can't be parsed!");
|
||||
}
|
||||
}
|
||||
|
||||
if (reg.equals(confReg) && output.getItemDamage() == meta) { return true; }
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean hasException(String ore) {
|
||||
for (String conf : ConfigStringListValues.CRUSHER_RECIPE_EXCEPTIONS.getValue()) {
|
||||
if (conf.equals(ore)) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static CrusherRecipe getRecipeFromInput(ItemStack input) {
|
||||
for (CrusherRecipe recipe : ActuallyAdditionsAPI.CRUSHER_RECIPES)
|
||||
if (recipe.matches(input)) return recipe;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class SearchCase {
|
||||
|
||||
final String theCase;
|
||||
final int resultAmount;
|
||||
final String resultPreString;
|
||||
|
||||
public SearchCase(String theCase, int resultAmount) {
|
||||
this(theCase, resultAmount, "dust");
|
||||
}
|
||||
|
||||
public SearchCase(String theCase, int resultAmount, String resultPreString) {
|
||||
this.theCase = theCase;
|
||||
this.resultAmount = resultAmount;
|
||||
this.resultPreString = resultPreString;
|
||||
}
|
||||
}
|
||||
//
|
||||
// public static final ArrayList<SearchCase> SEARCH_CASES = new ArrayList<>();
|
||||
//
|
||||
// public static void registerFinally() {
|
||||
// ArrayList<String> oresNoResult = new ArrayList<>();
|
||||
// int recipeStartedAt = ActuallyAdditionsAPI.CRUSHER_RECIPES.size();
|
||||
//
|
||||
// for (String ore : OreDictionary.getOreNames()) {
|
||||
// if (!hasException(ore)) {
|
||||
// for (SearchCase theCase : SEARCH_CASES) {
|
||||
// if (ore.length() > theCase.theCase.length()) {
|
||||
// if (ore.substring(0, theCase.theCase.length()).equals(theCase.theCase)) {
|
||||
// String outputOre = theCase.resultPreString + ore.substring(theCase.theCase.length());
|
||||
// List<ItemStack> outputs = OreDictionary.getOres(outputOre, false);
|
||||
// ItemStack output = outputs.isEmpty() ? ItemStack.EMPTY : outputs.get(0).copy();
|
||||
// output.setCount(theCase.resultAmount);
|
||||
// if (output.isEmpty()) {
|
||||
// if (!oresNoResult.contains(ore)) {
|
||||
// oresNoResult.add(ore);
|
||||
// }
|
||||
// } else ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient(ore), output, StackUtil.getEmpty(), 0);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// ArrayList<String> addedRecipes = new ArrayList<>();
|
||||
// for (int i = recipeStartedAt; i < ActuallyAdditionsAPI.CRUSHER_RECIPES.size(); i++) {
|
||||
// CrusherRecipe recipe = ActuallyAdditionsAPI.CRUSHER_RECIPES.get(i);
|
||||
// addedRecipes.add(recipe.getInput().getMatchingStacks() + " -> " + recipe.getOutputOne());
|
||||
// }
|
||||
// ActuallyAdditions.LOGGER.debug("Added " + addedRecipes.size() + " Crusher Recipes automatically: " + addedRecipes);
|
||||
// ActuallyAdditions.LOGGER.debug("Couldn't add " + oresNoResult.size() + " Crusher Recipes automatically, either because the inputs were missing outputs, or because they exist already: " + oresNoResult);
|
||||
// removeDuplicateRecipes();
|
||||
// }
|
||||
//
|
||||
// public static void removeDuplicateRecipes() {
|
||||
// ArrayList<CrusherRecipe> usable = new ArrayList<>();
|
||||
// ArrayList<CrusherRecipe> removed = new ArrayList<>();
|
||||
// for (CrusherRecipe r : ActuallyAdditionsAPI.CRUSHER_RECIPES) {
|
||||
// boolean canUse = true;
|
||||
// if (r.getInput().getMatchingStacks().length == 0) canUse = false;
|
||||
// else for (CrusherRecipe re : usable) {
|
||||
// if (re.getInput().apply(r.getInput().getMatchingStacks()[0])) canUse = false;
|
||||
// }
|
||||
//
|
||||
// if (canUse) usable.add(r);
|
||||
// else removed.add(r);
|
||||
// }
|
||||
//
|
||||
// ActuallyAdditionsAPI.CRUSHER_RECIPES.clear();
|
||||
// ActuallyAdditionsAPI.CRUSHER_RECIPES.addAll(usable);
|
||||
// ActuallyAdditions.LOGGER.debug(String.format("Removed %s crusher recipes that had dupliate inputs, %s remain.", removed.size(), usable.size()));
|
||||
// }
|
||||
//
|
||||
// public static boolean hasBlacklistedOutput(ItemStack output, String[] config) {
|
||||
// if (StackUtil.isValid(output)) {
|
||||
// Item item = output.getItem();
|
||||
// if (item != null) {
|
||||
// String reg = item.getRegistryName().toString();
|
||||
//
|
||||
// for (String conf : config) {
|
||||
// String confReg = conf;
|
||||
// int meta = 0;
|
||||
//
|
||||
// if (conf.contains("@")) {
|
||||
// try {
|
||||
// String[] split = conf.split("@");
|
||||
// confReg = split[0];
|
||||
// meta = Integer.parseInt(split[1]);
|
||||
// } catch (Exception e) {
|
||||
// ActuallyAdditions.LOGGER.warn("A config option appears to be incorrect: The entry " + conf + " can't be parsed!");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (reg.equals(confReg) && output.getItemDamage() == meta) { return true; }
|
||||
// }
|
||||
//
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// public static boolean hasException(String ore) {
|
||||
// for (String conf : ConfigStringListValues.CRUSHER_RECIPE_EXCEPTIONS.getValue()) {
|
||||
// if (conf.equals(ore)) { return true; }
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// public static CrusherRecipe getRecipeFromInput(ItemStack input) {
|
||||
// for (CrusherRecipe recipe : ActuallyAdditionsAPI.CRUSHER_RECIPES)
|
||||
// if (recipe.matches(input)) return recipe;
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// public static class SearchCase {
|
||||
//
|
||||
// final String theCase;
|
||||
// final int resultAmount;
|
||||
// final String resultPreString;
|
||||
//
|
||||
// public SearchCase(String theCase, int resultAmount) {
|
||||
// this(theCase, resultAmount, "dust");
|
||||
// }
|
||||
//
|
||||
// public SearchCase(String theCase, int resultAmount, String resultPreString) {
|
||||
// this.theCase = theCase;
|
||||
// this.resultAmount = resultAmount;
|
||||
// this.resultPreString = resultPreString;
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue