Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 27b8c5f3ac | |||
| 3043887915 | |||
| e0abe9b9a9 | |||
| e19991f1f9 | |||
| 3d97b1e3ec | |||
| 6b1bccffb9 | |||
| 6fab7b91b7 | |||
| 7b6bab4967 | |||
| 04766e5325 |
@@ -22,14 +22,14 @@ jobs:
|
||||
path: ~/.gradle/caches
|
||||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
|
||||
- name: Clean gradle
|
||||
run: ./gradlew clean --no-daemon
|
||||
run: ./gradlew clean --no-daemon --max-workers 1
|
||||
- name: Validate no assets
|
||||
run: test ! -d ./src/generated
|
||||
- name: Generate assets
|
||||
uses: GabrielBB/xvfb-action@v1.2
|
||||
with:
|
||||
run: ./gradlew runData --no-daemon
|
||||
run: ./gradlew runData --no-daemon --max-workers 1
|
||||
- name: Validate assets
|
||||
run: test -d ./src/generated -a -f ./src/generated/resources/.cache/cache
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build --no-daemon
|
||||
run: ./gradlew build --no-daemon --max-workers 1
|
||||
|
||||
@@ -22,14 +22,14 @@ jobs:
|
||||
path: ~/.gradle/caches
|
||||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
|
||||
- name: Clean gradle
|
||||
run: ./gradlew clean --no-daemon
|
||||
run: ./gradlew clean --no-daemon --max-workers 1
|
||||
- name: Validate no assets
|
||||
run: test ! -d ./src/generated
|
||||
- name: Generate assets
|
||||
uses: GabrielBB/xvfb-action@v1.2
|
||||
with:
|
||||
run: ./gradlew runData --no-daemon
|
||||
run: ./gradlew runData --no-daemon --max-workers 1
|
||||
- name: Validate assets
|
||||
run: test -d ./src/generated -a -f ./src/generated/resources/.cache/cache
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build --no-daemon
|
||||
run: ./gradlew build --no-daemon --max-workers 1
|
||||
|
||||
@@ -22,19 +22,19 @@ jobs:
|
||||
path: ~/.gradle/caches
|
||||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
|
||||
- name: Clean gradle
|
||||
run: ./gradlew clean --no-daemon
|
||||
run: ./gradlew clean --no-daemon --max-workers 1
|
||||
- name: Validate no assets
|
||||
run: test ! -d ./src/generated
|
||||
- name: Generate assets
|
||||
uses: GabrielBB/xvfb-action@v1.2
|
||||
with:
|
||||
run: ./gradlew runData --no-daemon
|
||||
run: ./gradlew runData --no-daemon --max-workers 1
|
||||
- name: Validate assets
|
||||
run: test -d ./src/generated -a -f ./src/generated/resources/.cache/cache
|
||||
- name: Build with Gradle
|
||||
env:
|
||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||
run: ./gradlew build --no-daemon
|
||||
run: ./gradlew build --no-daemon --max-workers 1
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: dist
|
||||
|
||||
@@ -33,7 +33,7 @@ jobs:
|
||||
- name: Generate assets
|
||||
uses: GabrielBB/xvfb-action@v1.2
|
||||
with:
|
||||
run: ./gradlew runData --no-daemon
|
||||
run: ./gradlew runData --no-daemon --max-workers 1
|
||||
- name: Validate assets
|
||||
run: test -d ./src/generated -a -f ./src/generated/resources/.cache/cache
|
||||
- name: Build with Gradle
|
||||
@@ -42,7 +42,7 @@ jobs:
|
||||
KEY_STORE_ALIAS: ${{ secrets.KEY_STORE_ALIAS }}
|
||||
KEY_STORE_KEY_PASS: ${{ secrets.KEY_STORE_KEY_PASS }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: ./gradlew build --no-daemon
|
||||
run: ./gradlew build --no-daemon --max-workers 1
|
||||
- name: Upload to curseforge
|
||||
env:
|
||||
KEY_STORE_PASS: ${{ secrets.KEY_STORE_PASS }}
|
||||
@@ -50,14 +50,14 @@ jobs:
|
||||
KEY_STORE_KEY_PASS: ${{ secrets.KEY_STORE_KEY_PASS }}
|
||||
CHANGELOG: ${{ github.event.release.body }}
|
||||
CURSEFORGE: ${{ secrets.CURSEFORGE }}
|
||||
run: ./gradlew curseforge --no-daemon
|
||||
run: ./gradlew curseforge --no-daemon --max-workers 1
|
||||
- name: Publish to github packages
|
||||
env:
|
||||
KEY_STORE_PASS: ${{ secrets.KEY_STORE_PASS }}
|
||||
KEY_STORE_ALIAS: ${{ secrets.KEY_STORE_ALIAS }}
|
||||
KEY_STORE_KEY_PASS: ${{ secrets.KEY_STORE_KEY_PASS }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: ./gradlew publish --no-daemon
|
||||
run: ./gradlew publish --no-daemon --max-workers 1
|
||||
- name: Prepare artifact metadata
|
||||
id: prepare_artifact_metadata
|
||||
run: |
|
||||
|
||||
@@ -50,6 +50,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.model.data.EmptyModelData;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.CapabilityProvider;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
|
||||
import appeng.api.networking.IGridNode;
|
||||
@@ -346,10 +347,12 @@ public interface IPart extends ICustomCableConnection {
|
||||
* capabilities on the cable bus will be forwarded to parts on the appropriate
|
||||
* side.
|
||||
*
|
||||
* @see TileEntity#getCapability(Capability, net.minecraft.util.Direction)
|
||||
* @see CapabilityProvider#getCapability(Capability,
|
||||
* net.minecraft.util.Direction)
|
||||
*
|
||||
* @return The capability or null.
|
||||
* @return The capability
|
||||
*/
|
||||
@Nonnull
|
||||
default <T> LazyOptional<T> getCapability(Capability<T> capabilityClass) {
|
||||
return LazyOptional.empty();
|
||||
}
|
||||
|
||||
@@ -154,14 +154,14 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
|
||||
|
||||
protected void drawGuiSlot(CustomSlotWidget slot, int mouseX, int mouseY, float partialTicks) {
|
||||
if (slot.isSlotEnabled()) {
|
||||
final int left = slot.xPos();
|
||||
final int top = slot.yPos();
|
||||
final int right = left + slot.getWidth();
|
||||
final int bottom = top + slot.getHeight();
|
||||
final int left = slot.getTooltipAreaX();
|
||||
final int top = slot.getTooltipAreaY();
|
||||
final int right = left + slot.getTooltipAreaWidth();
|
||||
final int bottom = top + slot.getTooltipAreaHeight();
|
||||
|
||||
slot.drawContent(getMinecraft(), mouseX, mouseY, partialTicks);
|
||||
|
||||
if (this.isPointInRegion(left, top, slot.getWidth(), slot.getHeight(), mouseX, mouseY)
|
||||
if (this.isPointInRegion(left, top, slot.getTooltipAreaWidth(), slot.getTooltipAreaHeight(), mouseX, mouseY)
|
||||
&& slot.canClick(getPlayer())) {
|
||||
RenderSystem.colorMask(true, true, true, false);
|
||||
this.fillGradient(left, top, right, bottom, -2130706433, -2130706433);
|
||||
@@ -171,16 +171,16 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
|
||||
}
|
||||
|
||||
private void drawTooltip(ITooltip tooltip, int mouseX, int mouseY) {
|
||||
final int x = tooltip.xPos(); // ((GuiImgButton) c).x;
|
||||
int y = tooltip.yPos(); // ((GuiImgButton) c).y;
|
||||
final int x = tooltip.getTooltipAreaX();
|
||||
int y = tooltip.getTooltipAreaY();
|
||||
|
||||
if (x < mouseX && x + tooltip.getWidth() > mouseX && tooltip.isVisible()) {
|
||||
if (y < mouseY && y + tooltip.getHeight() > mouseY) {
|
||||
if (x < mouseX && x + tooltip.getTooltipAreaWidth() > mouseX && tooltip.isTooltipAreaVisible()) {
|
||||
if (y < mouseY && y + tooltip.getTooltipAreaHeight() > mouseY) {
|
||||
if (y < 15) {
|
||||
y = 15;
|
||||
}
|
||||
|
||||
final String msg = tooltip.getMessage();
|
||||
final String msg = tooltip.getTooltipMessage();
|
||||
if (msg != null && !msg.isEmpty()) {
|
||||
this.drawTooltip(x + 11, y + 4, msg);
|
||||
}
|
||||
@@ -275,8 +275,8 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
|
||||
}
|
||||
|
||||
for (CustomSlotWidget slot : this.guiSlots) {
|
||||
if (this.isPointInRegion(slot.xPos(), slot.yPos(), slot.getWidth(), slot.getHeight(), xCoord, yCoord)
|
||||
&& slot.canClick(getPlayer())) {
|
||||
if (this.isPointInRegion(slot.getTooltipAreaX(), slot.getTooltipAreaY(), slot.getTooltipAreaWidth(),
|
||||
slot.getTooltipAreaHeight(), xCoord, yCoord) && slot.canClick(getPlayer())) {
|
||||
slot.slotClicked(getPlayer().inventory.getItemStack(), btn);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.regex.Pattern;
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
|
||||
public class ActionButton extends IconButton implements ITooltip {
|
||||
public class ActionButton extends IconButton {
|
||||
private static final Pattern PATTERN_NEW_LINE = Pattern.compile("\\n", Pattern.LITERAL);
|
||||
private final int iconIndex;
|
||||
|
||||
|
||||
@@ -34,32 +34,32 @@ public abstract class CustomSlotWidget extends AbstractGui implements ITooltip {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
public String getTooltipMessage() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos() {
|
||||
public int getTooltipAreaX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos() {
|
||||
public int getTooltipAreaY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
public int getTooltipAreaWidth() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
public int getTooltipAreaHeight() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
public boolean isTooltipAreaVisible() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,38 +28,38 @@ public interface ITooltip {
|
||||
*
|
||||
* @return tooltip message
|
||||
*/
|
||||
String getMessage();
|
||||
String getTooltipMessage();
|
||||
|
||||
/**
|
||||
* x Location for the object that triggers the tooltip.
|
||||
*
|
||||
* @return xPosition
|
||||
*/
|
||||
int xPos();
|
||||
int getTooltipAreaX();
|
||||
|
||||
/**
|
||||
* y Location for the object that triggers the tooltip.
|
||||
*
|
||||
* @return yPosition
|
||||
*/
|
||||
int yPos();
|
||||
int getTooltipAreaY();
|
||||
|
||||
/**
|
||||
* Width of the object that triggers the tooltip.
|
||||
*
|
||||
* @return width
|
||||
*/
|
||||
int getWidth();
|
||||
int getTooltipAreaWidth();
|
||||
|
||||
/**
|
||||
* Height for the object that triggers the tooltip.
|
||||
*
|
||||
* @return height
|
||||
*/
|
||||
int getHeight();
|
||||
int getTooltipAreaHeight();
|
||||
|
||||
/**
|
||||
* @return true if button being drawn
|
||||
*/
|
||||
boolean isVisible();
|
||||
boolean isTooltipAreaVisible();
|
||||
}
|
||||
|
||||
@@ -95,27 +95,32 @@ public abstract class IconButton extends Button implements ITooltip {
|
||||
protected abstract int getIconIndex();
|
||||
|
||||
@Override
|
||||
public int xPos() {
|
||||
public String getTooltipMessage() {
|
||||
return getMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTooltipAreaX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos() {
|
||||
public int getTooltipAreaY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
public int getTooltipAreaWidth() {
|
||||
return this.halfSize ? 8 : 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
public int getTooltipAreaHeight() {
|
||||
return this.halfSize ? 8 : 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
public boolean isTooltipAreaVisible() {
|
||||
return this.visible;
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ public class ProgressBar extends Widget implements ITooltip {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
public String getTooltipMessage() {
|
||||
if (this.fullMsg != null) {
|
||||
return this.fullMsg;
|
||||
}
|
||||
@@ -86,27 +86,27 @@ public class ProgressBar extends Widget implements ITooltip {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos() {
|
||||
public int getTooltipAreaX() {
|
||||
return this.x - 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos() {
|
||||
public int getTooltipAreaY() {
|
||||
return this.y - 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
public int getTooltipAreaWidth() {
|
||||
return this.width + 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
public int getTooltipAreaHeight() {
|
||||
return this.height + 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
public boolean isTooltipAreaVisible() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -278,7 +278,7 @@ public class SettingToggleButton<T extends Enum<T>> extends IconButton {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
public String getTooltipMessage() {
|
||||
ITextComponent displayName = null;
|
||||
ITextComponent displayValue = null;
|
||||
|
||||
|
||||
@@ -97,27 +97,32 @@ public class TabButton extends Button implements ITooltip {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos() {
|
||||
public String getTooltipMessage() {
|
||||
return getMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTooltipAreaX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos() {
|
||||
public int getTooltipAreaY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
public int getTooltipAreaWidth() {
|
||||
return 22;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
public int getTooltipAreaHeight() {
|
||||
return 22;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
public boolean isTooltipAreaVisible() {
|
||||
return this.visible;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ public class ToggleButton extends Button implements ITooltip {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
public String getTooltipMessage() {
|
||||
if (this.displayName != null) {
|
||||
String name = I18n.format(this.displayName);
|
||||
String value = I18n.format(this.displayHint);
|
||||
@@ -103,27 +103,27 @@ public class ToggleButton extends Button implements ITooltip {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos() {
|
||||
public int getTooltipAreaX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos() {
|
||||
public int getTooltipAreaY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
public int getTooltipAreaWidth() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
public int getTooltipAreaHeight() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
public boolean isTooltipAreaVisible() {
|
||||
return this.visible;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class FormationPlaneContainer extends UpgradeableContainer {
|
||||
return helper.open(player, locator);
|
||||
}
|
||||
|
||||
@GuiSync(6)
|
||||
@GuiSync(7)
|
||||
public YesNo placeMode;
|
||||
|
||||
public FormationPlaneContainer(int id, final PlayerInventory ip, final FormationPlanePart te) {
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
package appeng.core;
|
||||
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.IRecipeType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class AERecipeType<T extends IRecipe<?>> implements IRecipeType<T> {
|
||||
private final String id;
|
||||
|
||||
public AERecipeType(ResourceLocation registryName) {
|
||||
this.id = registryName.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
@@ -428,9 +428,6 @@ final class Registration {
|
||||
public void registerRecipeSerializers(RegistryEvent.Register<IRecipeSerializer<?>> event) {
|
||||
IForgeRegistry<IRecipeSerializer<?>> r = event.getRegistry();
|
||||
|
||||
GrinderRecipe.TYPE = new AERecipeType<>(GrinderRecipeSerializer.INSTANCE.getRegistryName());
|
||||
InscriberRecipe.TYPE = new AERecipeType<>(InscriberRecipeSerializer.INSTANCE.getRegistryName());
|
||||
|
||||
FacadeItem facadeItem = (FacadeItem) Api.INSTANCE.definitions().items().facade().item();
|
||||
r.registerAll(DisassembleRecipe.SERIALIZER, GrinderRecipeSerializer.INSTANCE,
|
||||
InscriberRecipeSerializer.INSTANCE, FacadeRecipe.getSerializer(facadeItem));
|
||||
|
||||
@@ -49,7 +49,7 @@ public class FacadePart implements IFacadePart {
|
||||
|
||||
@Override
|
||||
public void getBoxes(final IPartCollisionHelper ch, boolean livingEntity) {
|
||||
if (livingEntity) {
|
||||
if (livingEntity || !ch.isBBCollision()) {
|
||||
// prevent weird snag behavior
|
||||
ch.addBox(0.0, 0.0, 14, 16.0, 16.0, 16.0);
|
||||
} else {
|
||||
|
||||
@@ -52,7 +52,8 @@ public class FluidSlotWidget extends CustomSlotWidget {
|
||||
final float blue = (attributes.getColor() & 255) / 255.0F;
|
||||
RenderSystem.color3f(red, green, blue);
|
||||
|
||||
blit(xPos(), yPos(), this.getBlitOffset(), getWidth(), getHeight(), sprite);
|
||||
blit(getTooltipAreaX(), getTooltipAreaY(), this.getBlitOffset(), getTooltipAreaWidth(),
|
||||
getTooltipAreaHeight(), sprite);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +77,7 @@ public class FluidSlotWidget extends CustomSlotWidget {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
public String getTooltipMessage() {
|
||||
final IAEFluidStack fluid = this.getFluidStack();
|
||||
if (fluid != null) {
|
||||
return I18n.format(fluid.getFluidStack().getTranslationKey());
|
||||
@@ -85,7 +86,7 @@ public class FluidSlotWidget extends CustomSlotWidget {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
public boolean isTooltipAreaVisible() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ public class FluidTankWidget extends Widget implements ITooltip {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
public String getTooltipMessage() {
|
||||
final IAEFluidStack fluid = this.tank.getFluidInSlot(this.slot);
|
||||
if (fluid != null && fluid.getStackSize() > 0) {
|
||||
String desc = fluid.getFluid().getAttributes().getDisplayName(fluid.getFluidStack()).getFormattedText();
|
||||
@@ -97,27 +97,27 @@ public class FluidTankWidget extends Widget implements ITooltip {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos() {
|
||||
public int getTooltipAreaX() {
|
||||
return this.x - 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos() {
|
||||
public int getTooltipAreaY() {
|
||||
return this.y - 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
public int getTooltipAreaWidth() {
|
||||
return this.width + 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
public int getTooltipAreaHeight() {
|
||||
return this.height + 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
public boolean isTooltipAreaVisible() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,8 @@ public class OptionalFluidSlotWidget extends FluidSlotWidget {
|
||||
} else {
|
||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 0.4F);
|
||||
}
|
||||
GuiUtils.drawTexturedModalRect(guileft + this.xPos() - 1, guitop + this.yPos() - 1, this.srcX - 1,
|
||||
this.srcY - 1, this.getWidth() + 2, this.getHeight() + 2, currentZIndex);
|
||||
GuiUtils.drawTexturedModalRect(guileft + this.getTooltipAreaX() - 1, guitop + this.getTooltipAreaY() - 1,
|
||||
this.srcX - 1, this.srcY - 1, this.getTooltipAreaWidth() + 2, this.getTooltipAreaHeight() + 2,
|
||||
currentZIndex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ public class DualityFluidInterface
|
||||
} else if (capabilityClass == Capabilities.STORAGE_MONITORABLE_ACCESSOR) {
|
||||
return (LazyOptional<T>) LazyOptional.of(() -> this.accessor);
|
||||
}
|
||||
return null;
|
||||
return LazyOptional.empty();
|
||||
}
|
||||
|
||||
private boolean hasConfig() {
|
||||
|
||||
@@ -14,7 +14,6 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tags.FluidTags;
|
||||
import net.minecraft.tags.Tag;
|
||||
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.IBlockReader;
|
||||
@@ -35,15 +34,12 @@ import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartCollisionHelper;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.IPartModel;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.channels.IFluidStorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.settings.TickRates;
|
||||
@@ -53,6 +49,7 @@ import appeng.items.parts.PartModels;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.helpers.MachineSource;
|
||||
import appeng.parts.BasicStatePart;
|
||||
import appeng.parts.automation.PlaneConnectionHelper;
|
||||
import appeng.parts.automation.PlaneConnections;
|
||||
import appeng.parts.automation.PlaneModelData;
|
||||
import appeng.parts.automation.PlaneModels;
|
||||
@@ -73,115 +70,27 @@ public class FluidAnnihilationPlanePart extends BasicStatePart implements IGridT
|
||||
|
||||
private final IActionSource mySrc = new MachineSource(this);
|
||||
|
||||
private final PlaneConnectionHelper connectionHelper = new PlaneConnectionHelper(this);
|
||||
|
||||
public FluidAnnihilationPlanePart(final ItemStack is) {
|
||||
super(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes(final IPartCollisionHelper bch) {
|
||||
int minX = 1;
|
||||
int minY = 1;
|
||||
int maxX = 15;
|
||||
int maxY = 15;
|
||||
|
||||
final IPartHost host = this.getHost();
|
||||
if (host != null) {
|
||||
final TileEntity te = host.getTile();
|
||||
|
||||
final BlockPos pos = te.getPos();
|
||||
|
||||
final Direction e = bch.getWorldX();
|
||||
final Direction u = bch.getWorldY();
|
||||
|
||||
if (this.isAnnihilationPlane(te.getWorld().getTileEntity(pos.offset(e.getOpposite())), this.getSide())) {
|
||||
minX = 0;
|
||||
}
|
||||
|
||||
if (this.isAnnihilationPlane(te.getWorld().getTileEntity(pos.offset(e)), this.getSide())) {
|
||||
maxX = 16;
|
||||
}
|
||||
|
||||
if (this.isAnnihilationPlane(te.getWorld().getTileEntity(pos.offset(u.getOpposite())), this.getSide())) {
|
||||
minY = 0;
|
||||
}
|
||||
|
||||
if (this.isAnnihilationPlane(te.getWorld().getTileEntity(pos.offset(e)), this.getSide())) {
|
||||
maxY = 16;
|
||||
}
|
||||
}
|
||||
|
||||
bch.addBox(5, 5, 14, 11, 11, 15);
|
||||
bch.addBox(minX, minY, 15, maxX, maxY, 16);
|
||||
connectionHelper.getBoxes(bch);
|
||||
}
|
||||
|
||||
public PlaneConnections getConnections() {
|
||||
|
||||
final Direction facingRight, facingUp;
|
||||
AEPartLocation location = this.getSide();
|
||||
switch (location) {
|
||||
case UP:
|
||||
facingRight = Direction.EAST;
|
||||
facingUp = Direction.NORTH;
|
||||
break;
|
||||
case DOWN:
|
||||
facingRight = Direction.WEST;
|
||||
facingUp = Direction.NORTH;
|
||||
break;
|
||||
case NORTH:
|
||||
facingRight = Direction.WEST;
|
||||
facingUp = Direction.UP;
|
||||
break;
|
||||
case SOUTH:
|
||||
facingRight = Direction.EAST;
|
||||
facingUp = Direction.UP;
|
||||
break;
|
||||
case WEST:
|
||||
facingRight = Direction.SOUTH;
|
||||
facingUp = Direction.UP;
|
||||
break;
|
||||
case EAST:
|
||||
facingRight = Direction.NORTH;
|
||||
facingUp = Direction.UP;
|
||||
break;
|
||||
default:
|
||||
case INTERNAL:
|
||||
return PlaneConnections.of(false, false, false, false);
|
||||
}
|
||||
|
||||
boolean left = false, right = false, down = false, up = false;
|
||||
|
||||
final IPartHost host = this.getHost();
|
||||
if (host != null) {
|
||||
final TileEntity te = host.getTile();
|
||||
|
||||
final BlockPos pos = te.getPos();
|
||||
|
||||
if (this.isAnnihilationPlane(te.getWorld().getTileEntity(pos.offset(facingRight.getOpposite())),
|
||||
this.getSide())) {
|
||||
left = true;
|
||||
}
|
||||
|
||||
if (this.isAnnihilationPlane(te.getWorld().getTileEntity(pos.offset(facingRight)), this.getSide())) {
|
||||
right = true;
|
||||
}
|
||||
|
||||
if (this.isAnnihilationPlane(te.getWorld().getTileEntity(pos.offset(facingUp.getOpposite())),
|
||||
this.getSide())) {
|
||||
down = true;
|
||||
}
|
||||
|
||||
if (this.isAnnihilationPlane(te.getWorld().getTileEntity(pos.offset(facingUp)), this.getSide())) {
|
||||
up = true;
|
||||
}
|
||||
}
|
||||
|
||||
return PlaneConnections.of(up, right, down, left);
|
||||
return connectionHelper.getConnections();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged(IBlockReader w, BlockPos pos, BlockPos neighbor) {
|
||||
if (pos.offset(this.getSide().getFacing()).equals(neighbor)) {
|
||||
this.refresh();
|
||||
} else {
|
||||
connectionHelper.updateConnections();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,14 +99,6 @@ public class FluidAnnihilationPlanePart extends BasicStatePart implements IGridT
|
||||
return 1;
|
||||
}
|
||||
|
||||
private boolean isAnnihilationPlane(final TileEntity blockTileEntity, final AEPartLocation side) {
|
||||
if (blockTileEntity instanceof IPartHost) {
|
||||
final IPart p = ((IPartHost) blockTileEntity).getPart(side);
|
||||
return p != null && p.getClass() == this.getClass();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void refresh() {
|
||||
try {
|
||||
this.getProxy().getTick().alertDevice(this.getProxy().getNode());
|
||||
|
||||
@@ -4,16 +4,13 @@ package appeng.parts.automation;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartCollisionHelper;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.cells.ICellContainer;
|
||||
import appeng.api.storage.cells.ICellInventory;
|
||||
@@ -30,6 +27,7 @@ public abstract class AbstractFormationPlanePart<T extends IAEStack<T>> extends
|
||||
private boolean wasActive = false;
|
||||
private int priority = 0;
|
||||
protected boolean blocked = false;
|
||||
private final PlaneConnectionHelper connectionHelper = new PlaneConnectionHelper(this);
|
||||
|
||||
public AbstractFormationPlanePart(ItemStack is) {
|
||||
super(is);
|
||||
@@ -64,103 +62,11 @@ public abstract class AbstractFormationPlanePart<T extends IAEStack<T>> extends
|
||||
|
||||
@Override
|
||||
public void getBoxes(final IPartCollisionHelper bch) {
|
||||
int minX = 1;
|
||||
int minY = 1;
|
||||
int maxX = 15;
|
||||
int maxY = 15;
|
||||
|
||||
final IPartHost host = this.getHost();
|
||||
if (host != null) {
|
||||
final TileEntity te = host.getTile();
|
||||
|
||||
final BlockPos pos = te.getPos();
|
||||
|
||||
final Direction e = bch.getWorldX();
|
||||
final Direction u = bch.getWorldY();
|
||||
|
||||
if (this.isTransitionPlane(te.getWorld().getTileEntity(pos.offset(e.getOpposite())), this.getSide())) {
|
||||
minX = 0;
|
||||
}
|
||||
|
||||
if (this.isTransitionPlane(te.getWorld().getTileEntity(pos.offset(e)), this.getSide())) {
|
||||
maxX = 16;
|
||||
}
|
||||
|
||||
if (this.isTransitionPlane(te.getWorld().getTileEntity(pos.offset(u.getOpposite())), this.getSide())) {
|
||||
minY = 0;
|
||||
}
|
||||
|
||||
if (this.isTransitionPlane(te.getWorld().getTileEntity(pos.offset(u)), this.getSide())) {
|
||||
maxY = 16;
|
||||
}
|
||||
}
|
||||
|
||||
bch.addBox(5, 5, 14, 11, 11, 15);
|
||||
bch.addBox(minX, minY, 15, maxX, maxY, 16);
|
||||
connectionHelper.getBoxes(bch);
|
||||
}
|
||||
|
||||
public PlaneConnections getConnections() {
|
||||
|
||||
final Direction facingRight, facingUp;
|
||||
AEPartLocation location = this.getSide();
|
||||
switch (location) {
|
||||
case UP:
|
||||
facingRight = Direction.EAST;
|
||||
facingUp = Direction.NORTH;
|
||||
break;
|
||||
case DOWN:
|
||||
facingRight = Direction.WEST;
|
||||
facingUp = Direction.NORTH;
|
||||
break;
|
||||
case NORTH:
|
||||
facingRight = Direction.WEST;
|
||||
facingUp = Direction.UP;
|
||||
break;
|
||||
case SOUTH:
|
||||
facingRight = Direction.EAST;
|
||||
facingUp = Direction.UP;
|
||||
break;
|
||||
case WEST:
|
||||
facingRight = Direction.SOUTH;
|
||||
facingUp = Direction.UP;
|
||||
break;
|
||||
case EAST:
|
||||
facingRight = Direction.NORTH;
|
||||
facingUp = Direction.UP;
|
||||
break;
|
||||
default:
|
||||
case INTERNAL:
|
||||
return PlaneConnections.of(false, false, false, false);
|
||||
}
|
||||
|
||||
boolean left = false, right = false, down = false, up = false;
|
||||
|
||||
final IPartHost host = this.getHost();
|
||||
if (host != null) {
|
||||
final TileEntity te = host.getTile();
|
||||
|
||||
final BlockPos pos = te.getPos();
|
||||
|
||||
if (this.isTransitionPlane(te.getWorld().getTileEntity(pos.offset(facingRight.getOpposite())),
|
||||
this.getSide())) {
|
||||
left = true;
|
||||
}
|
||||
|
||||
if (this.isTransitionPlane(te.getWorld().getTileEntity(pos.offset(facingRight)), this.getSide())) {
|
||||
right = true;
|
||||
}
|
||||
|
||||
if (this.isTransitionPlane(te.getWorld().getTileEntity(pos.offset(facingUp.getOpposite())),
|
||||
this.getSide())) {
|
||||
down = true;
|
||||
}
|
||||
|
||||
if (this.isTransitionPlane(te.getWorld().getTileEntity(pos.offset(facingUp)), this.getSide())) {
|
||||
up = true;
|
||||
}
|
||||
}
|
||||
|
||||
return PlaneConnections.of(up, right, down, left);
|
||||
return connectionHelper.getConnections();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -172,6 +78,8 @@ public abstract class AbstractFormationPlanePart<T extends IAEStack<T>> extends
|
||||
final BlockPos tePos = te.getPos().offset(side.getFacing());
|
||||
|
||||
this.blocked = !w.getBlockState(tePos).getMaterial().isReplaceable();
|
||||
} else {
|
||||
connectionHelper.updateConnections();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,14 +88,6 @@ public abstract class AbstractFormationPlanePart<T extends IAEStack<T>> extends
|
||||
return 1;
|
||||
}
|
||||
|
||||
protected boolean isTransitionPlane(final TileEntity blockTileEntity, final AEPartLocation side) {
|
||||
if (blockTileEntity instanceof IPartHost) {
|
||||
final IPart p = ((IPartHost) blockTileEntity).getPart(side);
|
||||
return p != null && this.getClass() == p.getClass();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T extractItems(final T request, final Actionable mode, final IActionSource src) {
|
||||
return null;
|
||||
|
||||
@@ -35,7 +35,6 @@ import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -58,9 +57,7 @@ import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartCollisionHelper;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.IPartModel;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
@@ -96,53 +93,31 @@ public class AnnihilationPlanePart extends BasicStatePart implements IGridTickab
|
||||
private boolean isAccepting = true;
|
||||
private boolean breaking = false;
|
||||
|
||||
private final PlaneConnectionHelper connectionHelper = new PlaneConnectionHelper(this);
|
||||
|
||||
public AnnihilationPlanePart(final ItemStack is) {
|
||||
super(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickRateModulation call(final World world) throws Exception {
|
||||
public TickRateModulation call(final World world) {
|
||||
this.breaking = false;
|
||||
return this.breakBlock(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes(final IPartCollisionHelper bch) {
|
||||
int minX = 1;
|
||||
int minY = 1;
|
||||
int maxX = 15;
|
||||
int maxY = 15;
|
||||
|
||||
final IPartHost host = this.getHost();
|
||||
if (host != null) {
|
||||
final TileEntity te = host.getTile();
|
||||
|
||||
final BlockPos pos = te.getPos();
|
||||
|
||||
final Direction e = bch.getWorldX();
|
||||
final Direction u = bch.getWorldY();
|
||||
|
||||
if (this.isAnnihilationPlane(te.getWorld().getTileEntity(pos.offset(e.getOpposite())), this.getSide())) {
|
||||
minX = 0;
|
||||
}
|
||||
|
||||
if (this.isAnnihilationPlane(te.getWorld().getTileEntity(pos.offset(e)), this.getSide())) {
|
||||
maxX = 16;
|
||||
}
|
||||
|
||||
if (this.isAnnihilationPlane(te.getWorld().getTileEntity(pos.offset(u.getOpposite())), this.getSide())) {
|
||||
minY = 0;
|
||||
}
|
||||
|
||||
if (this.isAnnihilationPlane(te.getWorld().getTileEntity(pos.offset(e)), this.getSide())) {
|
||||
maxY = 16;
|
||||
}
|
||||
// For collision, we're using a simplified bounding box
|
||||
if (bch.isBBCollision()) {
|
||||
// The smaller collision hitbox here is needed to allow for the entity collision
|
||||
// event
|
||||
bch.addBox(0, 0, 14, 16, 16, 15.5);
|
||||
return;
|
||||
}
|
||||
|
||||
bch.addBox(5, 5, 14, 11, 11, 15);
|
||||
// The smaller collision hitbox here is needed to allow for the entity collision
|
||||
// event
|
||||
bch.addBox(minX, minY, 15, maxX, maxY, bch.isBBCollision() ? 15 : 16);
|
||||
connectionHelper.getBoxes(bch);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -150,73 +125,15 @@ public class AnnihilationPlanePart extends BasicStatePart implements IGridTickab
|
||||
* visually.
|
||||
*/
|
||||
public PlaneConnections getConnections() {
|
||||
|
||||
final Direction facingRight, facingUp;
|
||||
AEPartLocation location = this.getSide();
|
||||
switch (location) {
|
||||
case UP:
|
||||
facingRight = Direction.EAST;
|
||||
facingUp = Direction.NORTH;
|
||||
break;
|
||||
case DOWN:
|
||||
facingRight = Direction.WEST;
|
||||
facingUp = Direction.NORTH;
|
||||
break;
|
||||
case NORTH:
|
||||
facingRight = Direction.WEST;
|
||||
facingUp = Direction.UP;
|
||||
break;
|
||||
case SOUTH:
|
||||
facingRight = Direction.EAST;
|
||||
facingUp = Direction.UP;
|
||||
break;
|
||||
case WEST:
|
||||
facingRight = Direction.SOUTH;
|
||||
facingUp = Direction.UP;
|
||||
break;
|
||||
case EAST:
|
||||
facingRight = Direction.NORTH;
|
||||
facingUp = Direction.UP;
|
||||
break;
|
||||
default:
|
||||
case INTERNAL:
|
||||
return PlaneConnections.of(false, false, false, false);
|
||||
}
|
||||
|
||||
boolean left = false, right = false, down = false, up = false;
|
||||
|
||||
final IPartHost host = this.getHost();
|
||||
if (host != null) {
|
||||
final TileEntity te = host.getTile();
|
||||
|
||||
final BlockPos pos = te.getPos();
|
||||
|
||||
if (this.isAnnihilationPlane(te.getWorld().getTileEntity(pos.offset(facingRight.getOpposite())),
|
||||
this.getSide())) {
|
||||
left = true;
|
||||
}
|
||||
|
||||
if (this.isAnnihilationPlane(te.getWorld().getTileEntity(pos.offset(facingRight)), this.getSide())) {
|
||||
right = true;
|
||||
}
|
||||
|
||||
if (this.isAnnihilationPlane(te.getWorld().getTileEntity(pos.offset(facingUp.getOpposite())),
|
||||
this.getSide())) {
|
||||
down = true;
|
||||
}
|
||||
|
||||
if (this.isAnnihilationPlane(te.getWorld().getTileEntity(pos.offset(facingUp)), this.getSide())) {
|
||||
up = true;
|
||||
}
|
||||
}
|
||||
|
||||
return PlaneConnections.of(up, right, down, left);
|
||||
return connectionHelper.getConnections();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged(IBlockReader w, BlockPos pos, BlockPos neighbor) {
|
||||
if (pos.offset(this.getSide().getFacing()).equals(neighbor)) {
|
||||
this.refresh();
|
||||
} else {
|
||||
connectionHelper.updateConnections();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -362,14 +279,6 @@ public class AnnihilationPlanePart extends BasicStatePart implements IGridTickab
|
||||
return changed;
|
||||
}
|
||||
|
||||
protected boolean isAnnihilationPlane(final TileEntity blockTileEntity, final AEPartLocation side) {
|
||||
if (blockTileEntity instanceof IPartHost) {
|
||||
final IPart p = ((IPartHost) blockTileEntity).getPart(side);
|
||||
return p != null && p.getClass() == this.getClass();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@MENetworkEventSubscribe
|
||||
public void chanRender(final MENetworkChannelsChanged c) {
|
||||
|
||||
@@ -21,26 +21,23 @@ package appeng.parts.automation;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.DirectionalPlaceContext;
|
||||
import net.minecraft.item.FireworkRocketItem;
|
||||
import net.minecraft.item.FireworkStarItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.item.WallOrFloorItem;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -49,7 +46,6 @@ import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
@@ -64,7 +60,6 @@ import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.parts.IPartItem;
|
||||
import appeng.api.parts.IPartModel;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.IStorageChannel;
|
||||
@@ -89,6 +84,7 @@ import appeng.util.prioritylist.PrecisePriorityList;
|
||||
public class FormationPlanePart extends AbstractFormationPlanePart<IAEItemStack> {
|
||||
|
||||
private static final PlaneModels MODELS = new PlaneModels("part/formation_plane", "part/formation_plane_on");
|
||||
private static final Random RANDOM_OFFSET = new Random();
|
||||
|
||||
@PartModels
|
||||
public static List<IPartModel> getModels() {
|
||||
@@ -222,12 +218,12 @@ public class FormationPlanePart extends AbstractFormationPlanePart<IAEItemStack>
|
||||
final BlockPos placePos = te.getPos().offset(side.getFacing());
|
||||
|
||||
if (w.getBlockState(placePos).getMaterial().isReplaceable()) {
|
||||
if (placeBlock == YesNo.YES && (i instanceof BlockItem || i instanceof IPlantable
|
||||
|| i instanceof FireworkStarItem || i instanceof FireworkRocketItem || i instanceof IPartItem)) {
|
||||
if (placeBlock == YesNo.YES) {
|
||||
final PlayerEntity player = Platform.getPlayer((ServerWorld) w);
|
||||
Platform.configurePlayer(player, side, this.getTile());
|
||||
Hand hand = player.getActiveHand();
|
||||
player.setHeldItem(hand, is);
|
||||
// Seems to work without...
|
||||
// Hand hand = player.getActiveHand();
|
||||
// player.setHeldItem(hand, is);
|
||||
|
||||
maxStorage = is.getCount();
|
||||
worked = true;
|
||||
@@ -235,84 +231,33 @@ public class FormationPlanePart extends AbstractFormationPlanePart<IAEItemStack>
|
||||
// The side the plane is attached to will be considered the look direction
|
||||
// in terms of placing an item
|
||||
Direction lookDirection = side.getFacing();
|
||||
PlaneDirectionalPlaceContext context = new PlaneDirectionalPlaceContext(w, player, placePos,
|
||||
lookDirection, is, lookDirection.getOpposite());
|
||||
|
||||
// FIXME No idea what any of this is _supposed_ to do, comment badly needed
|
||||
if (i instanceof IPlantable || i instanceof WallOrFloorItem) {
|
||||
boolean Worked = false;
|
||||
i.onItemUse(context);
|
||||
maxStorage -= is.getCount();
|
||||
|
||||
// Up or Down, Attempt 1??
|
||||
if (side.xOffset == 0 && side.zOffset == 0) {
|
||||
Worked = i.onItemUse(new DirectionalPlaceContext(w, placePos.offset(side.getFacing()),
|
||||
lookDirection, is, side.getFacing())) == ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
// Up or Down, Attempt 2??
|
||||
if (!Worked && side.xOffset == 0 && side.zOffset == 0) {
|
||||
Worked = i.onItemUse(new DirectionalPlaceContext(w,
|
||||
placePos.offset(side.getFacing().getOpposite()), lookDirection, is,
|
||||
side.getFacing().getOpposite())) == ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
// Horizontal, attempt 1??
|
||||
if (!Worked && side.yOffset == 0) {
|
||||
Worked = i.onItemUse(new DirectionalPlaceContext(w, placePos.offset(Direction.DOWN),
|
||||
lookDirection, is, Direction.DOWN)) == ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
if (!Worked) {
|
||||
i.onItemUse(new DirectionalPlaceContext(w, placePos, lookDirection, is,
|
||||
lookDirection.getOpposite()));
|
||||
}
|
||||
|
||||
maxStorage -= is.getCount();
|
||||
} else {
|
||||
i.onItemUse(new DirectionalPlaceContext(w, placePos, lookDirection, is,
|
||||
lookDirection.getOpposite()));
|
||||
maxStorage -= is.getCount();
|
||||
}
|
||||
} else {
|
||||
maxStorage = 1;
|
||||
}
|
||||
|
||||
// Safe keeping
|
||||
player.setHeldItem(hand, ItemStack.EMPTY);
|
||||
// Seems to work without... Safe keeping
|
||||
// player.setHeldItem(hand, ItemStack.EMPTY);
|
||||
} else {
|
||||
worked = true;
|
||||
|
||||
final int sum = this.countEntitesAround(w, placePos);
|
||||
|
||||
// Disable spawning once there is a certain amount of entities in an area.
|
||||
if (sum < AEConfig.instance().getFormationPlaneEntityLimit()) {
|
||||
worked = true;
|
||||
|
||||
if (type == Actionable.MODULATE) {
|
||||
is.setCount((int) maxStorage);
|
||||
final double x = (side.xOffset != 0 ? 0 : .7 * (Platform.getRandomFloat() - .5)) + side.xOffset
|
||||
+ .5 + te.getPos().getX();
|
||||
final double y = (side.yOffset != 0 ? 0 : .7 * (Platform.getRandomFloat() - .5)) + side.yOffset
|
||||
+ .5 + te.getPos().getY();
|
||||
final double z = (side.zOffset != 0 ? 0 : .7 * (Platform.getRandomFloat() - .5)) + side.zOffset
|
||||
+ .5 + te.getPos().getZ();
|
||||
|
||||
final ItemEntity ei = new ItemEntity(w, x, y, z, is.copy());
|
||||
|
||||
Entity result = ei;
|
||||
|
||||
ei.setMotion(side.xOffset * 0.2, side.yOffset * 0.2, side.zOffset * 0.2);
|
||||
|
||||
if (is.getItem().hasCustomEntity(is)) {
|
||||
result = is.getItem().createEntity(w, ei, is);
|
||||
if (result != null) {
|
||||
ei.remove();
|
||||
} else {
|
||||
result = ei;
|
||||
}
|
||||
}
|
||||
|
||||
if (!w.addEntity(result)) {
|
||||
result.remove();
|
||||
if (!spawnItemEntity(w, te, side, is)) {
|
||||
// revert in case something prevents spawning.
|
||||
worked = false;
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
worked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -331,6 +276,57 @@ public class FormationPlanePart extends AbstractFormationPlanePart<IAEItemStack>
|
||||
return input;
|
||||
}
|
||||
|
||||
private static boolean spawnItemEntity(World w, TileEntity te, AEPartLocation side, ItemStack is) {
|
||||
// the item offset based on the entity height plus some offset
|
||||
final double itemOffset = .55 + EntityType.ITEM.getHeight();
|
||||
|
||||
// The center of the block the plane is located in
|
||||
final double centerX = te.getPos().getX() + .5;
|
||||
final double centerY = te.getPos().getY() + .5;
|
||||
final double centerZ = te.getPos().getZ() + .5;
|
||||
|
||||
// When spawning downwards, we have to take the item height of 0.25 into account
|
||||
// Otherwise it will get stuck and be spit out in a random direction as
|
||||
// minecraft spawns it at its feet position and not center
|
||||
final double additionalYOffset = side.yOffset == -1 ? -.3 : 0;
|
||||
|
||||
// Calculate the offsets to spawn it into the adjacent block, taking the sign
|
||||
// into account.
|
||||
// Spawn it 0.8 blocks away from the center pos when facing in this direction
|
||||
// Every other direction will select a position in a .5 block area around the
|
||||
// block center.
|
||||
final double offsetX = (side.xOffset == 0) ? ((RANDOM_OFFSET.nextFloat() / 2) - .25)
|
||||
: (side.xOffset * itemOffset);
|
||||
final double offsetY = (side.yOffset == 0) ? ((RANDOM_OFFSET.nextFloat() / 2) - .25)
|
||||
: ((side.yOffset * itemOffset) + additionalYOffset);
|
||||
final double offsetZ = (side.zOffset == 0) ? ((RANDOM_OFFSET.nextFloat() / 2) - .25)
|
||||
: (side.zOffset * itemOffset);
|
||||
|
||||
final double absoluteX = centerX + offsetX;
|
||||
final double absoluteY = centerY + offsetY;
|
||||
final double absoluteZ = centerZ + offsetZ;
|
||||
|
||||
final ItemEntity ei = new ItemEntity(w, absoluteX, absoluteY, absoluteZ, is.copy());
|
||||
Entity result = ei;
|
||||
|
||||
ei.setMotion(side.xOffset * .1, side.yOffset * 0.1, side.zOffset * 0.1);
|
||||
|
||||
if (is.getItem().hasCustomEntity(is)) {
|
||||
result = is.getItem().createEntity(w, ei, is);
|
||||
if (result != null) {
|
||||
ei.remove();
|
||||
} else {
|
||||
result = ei;
|
||||
}
|
||||
}
|
||||
|
||||
if (!w.addEntity(result)) {
|
||||
result.remove();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStorageChannel<IAEItemStack> getChannel() {
|
||||
return Api.instance().storage().getStorageChannel(IItemStorageChannel.class);
|
||||
@@ -364,11 +360,69 @@ public class FormationPlanePart extends AbstractFormationPlanePart<IAEItemStack>
|
||||
return list.size();
|
||||
}
|
||||
|
||||
private class ForcedItemUseContext extends ItemUseContext {
|
||||
protected ForcedItemUseContext(World worldIn, @Nullable PlayerEntity player, Hand handIn, ItemStack heldItem,
|
||||
BlockRayTraceResult rayTraceResultIn) {
|
||||
super(worldIn, player, handIn, heldItem, rayTraceResultIn);
|
||||
/**
|
||||
* A custom {@link DirectionalPlaceContext} which also accepts a player needed
|
||||
* various blocks like seeds.
|
||||
* <p>
|
||||
* Also removed {@link DirectionalPlaceContext#replacingClickedOnBlock} as this
|
||||
* can cause a {@link StackOverflowError} for certain replaceable blocks.
|
||||
*/
|
||||
private static class PlaneDirectionalPlaceContext extends BlockItemUseContext {
|
||||
private final Direction lookDirection;
|
||||
|
||||
public PlaneDirectionalPlaceContext(World world, PlayerEntity player, BlockPos pos, Direction lookDirection,
|
||||
ItemStack itemStack, Direction facing) {
|
||||
super(world, player, Hand.MAIN_HAND, itemStack, new BlockRayTraceResult(
|
||||
new Vec3d(pos.getX() + 0.5D, pos.getY(), pos.getZ() + 0.5D), facing, pos, false));
|
||||
this.lookDirection = lookDirection;
|
||||
}
|
||||
|
||||
public BlockPos getPos() {
|
||||
return this.rayTraceResult.getPos();
|
||||
}
|
||||
|
||||
public boolean canPlace() {
|
||||
return this.world.getBlockState(this.rayTraceResult.getPos()).isReplaceable(this);
|
||||
}
|
||||
|
||||
public Direction getNearestLookingDirection() {
|
||||
return Direction.DOWN;
|
||||
}
|
||||
|
||||
public Direction[] getNearestLookingDirections() {
|
||||
switch (this.lookDirection) {
|
||||
case DOWN:
|
||||
default:
|
||||
return new Direction[] { Direction.DOWN, Direction.NORTH, Direction.EAST, Direction.SOUTH,
|
||||
Direction.WEST, Direction.UP };
|
||||
case UP:
|
||||
return new Direction[] { Direction.DOWN, Direction.UP, Direction.NORTH, Direction.EAST,
|
||||
Direction.SOUTH, Direction.WEST };
|
||||
case NORTH:
|
||||
return new Direction[] { Direction.DOWN, Direction.NORTH, Direction.EAST, Direction.WEST,
|
||||
Direction.UP, Direction.SOUTH };
|
||||
case SOUTH:
|
||||
return new Direction[] { Direction.DOWN, Direction.SOUTH, Direction.EAST, Direction.WEST,
|
||||
Direction.UP, Direction.NORTH };
|
||||
case WEST:
|
||||
return new Direction[] { Direction.DOWN, Direction.WEST, Direction.SOUTH, Direction.UP,
|
||||
Direction.NORTH, Direction.EAST };
|
||||
case EAST:
|
||||
return new Direction[] { Direction.DOWN, Direction.EAST, Direction.SOUTH, Direction.UP,
|
||||
Direction.NORTH, Direction.WEST };
|
||||
}
|
||||
}
|
||||
|
||||
public Direction getPlacementHorizontalFacing() {
|
||||
return this.lookDirection.getAxis() == Axis.Y ? Direction.NORTH : this.lookDirection;
|
||||
}
|
||||
|
||||
public boolean func_225518_g_() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public float getPlacementYaw() {
|
||||
return (float) (this.lookDirection.getHorizontalIndex() * 90);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -55,15 +55,6 @@ public class IdentityAnnihilationPlanePart extends AnnihilationPlanePart {
|
||||
super(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAnnihilationPlane(final TileEntity blockTileEntity, final AEPartLocation side) {
|
||||
if (blockTileEntity instanceof IPartHost) {
|
||||
final IPart p = ((IPartHost) blockTileEntity).getPart(side);
|
||||
return p != null && p.getClass() == this.getClass();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float calculateEnergyUsage(final ServerWorld w, final BlockPos pos, final List<ItemStack> items) {
|
||||
final float requiredEnergy = super.calculateEnergyUsage(w, pos, items);
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
package appeng.parts.automation;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartCollisionHelper;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.parts.AEBasePart;
|
||||
|
||||
/**
|
||||
* Helps plane parts (annihilation, formation) with determining and checking for
|
||||
* connections to adjacent plane parts of the same type to form a visually
|
||||
* larger plane.
|
||||
*/
|
||||
public final class PlaneConnectionHelper {
|
||||
|
||||
private final AEBasePart part;
|
||||
|
||||
public PlaneConnectionHelper(AEBasePart part) {
|
||||
this.part = part;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets on which sides this part has adjacent planes that it visually connects
|
||||
* to
|
||||
*/
|
||||
public PlaneConnections getConnections() {
|
||||
TileEntity hostTileEntity = getHostTileEntity();
|
||||
AEPartLocation side = part.getSide();
|
||||
|
||||
final Direction facingRight, facingUp;
|
||||
switch (side) {
|
||||
case UP:
|
||||
facingRight = Direction.EAST;
|
||||
facingUp = Direction.NORTH;
|
||||
break;
|
||||
case DOWN:
|
||||
facingRight = Direction.WEST;
|
||||
facingUp = Direction.NORTH;
|
||||
break;
|
||||
case NORTH:
|
||||
facingRight = Direction.WEST;
|
||||
facingUp = Direction.UP;
|
||||
break;
|
||||
case SOUTH:
|
||||
facingRight = Direction.EAST;
|
||||
facingUp = Direction.UP;
|
||||
break;
|
||||
case WEST:
|
||||
facingRight = Direction.SOUTH;
|
||||
facingUp = Direction.UP;
|
||||
break;
|
||||
case EAST:
|
||||
facingRight = Direction.NORTH;
|
||||
facingUp = Direction.UP;
|
||||
break;
|
||||
default:
|
||||
case INTERNAL:
|
||||
return PlaneConnections.of(false, false, false, false);
|
||||
}
|
||||
|
||||
boolean left = false, right = false, down = false, up = false;
|
||||
|
||||
if (hostTileEntity != null) {
|
||||
World world = hostTileEntity.getWorld();
|
||||
BlockPos pos = hostTileEntity.getPos();
|
||||
|
||||
if (isCompatiblePlaneAdjacent(world.getTileEntity(pos.offset(facingRight.getOpposite())))) {
|
||||
left = true;
|
||||
}
|
||||
|
||||
if (isCompatiblePlaneAdjacent(world.getTileEntity(pos.offset(facingRight)))) {
|
||||
right = true;
|
||||
}
|
||||
|
||||
if (isCompatiblePlaneAdjacent(world.getTileEntity(pos.offset(facingUp.getOpposite())))) {
|
||||
down = true;
|
||||
}
|
||||
|
||||
if (isCompatiblePlaneAdjacent(world.getTileEntity(pos.offset(facingUp)))) {
|
||||
up = true;
|
||||
}
|
||||
}
|
||||
|
||||
return PlaneConnections.of(up, right, down, left);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the bounding boxes of this plane parts components.
|
||||
*/
|
||||
public void getBoxes(IPartCollisionHelper bch) {
|
||||
int minX = 1;
|
||||
int minY = 1;
|
||||
int maxX = 15;
|
||||
int maxY = 15;
|
||||
|
||||
TileEntity hostTile = getHostTileEntity();
|
||||
if (hostTile != null) {
|
||||
World world = hostTile.getWorld();
|
||||
|
||||
final BlockPos pos = hostTile.getPos();
|
||||
|
||||
final Direction e = bch.getWorldX();
|
||||
final Direction u = bch.getWorldY();
|
||||
|
||||
if (isCompatiblePlaneAdjacent(world.getTileEntity(pos.offset(e.getOpposite())))) {
|
||||
minX = 0;
|
||||
}
|
||||
|
||||
if (isCompatiblePlaneAdjacent(world.getTileEntity(pos.offset(e)))) {
|
||||
maxX = 16;
|
||||
}
|
||||
|
||||
if (isCompatiblePlaneAdjacent(world.getTileEntity(pos.offset(u.getOpposite())))) {
|
||||
minY = 0;
|
||||
}
|
||||
|
||||
if (isCompatiblePlaneAdjacent(world.getTileEntity(pos.offset(u)))) {
|
||||
maxY = 16;
|
||||
}
|
||||
}
|
||||
|
||||
bch.addBox(5, 5, 14, 11, 11, 15);
|
||||
bch.addBox(minX, minY, 15, maxX, maxY, 16);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this when an adjacent block has changed since the connections need to be
|
||||
* recalculated.
|
||||
*/
|
||||
public void updateConnections() {
|
||||
TileEntity hostTile = getHostTileEntity();
|
||||
if (hostTile != null) {
|
||||
hostTile.requestModelDataUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isCompatiblePlaneAdjacent(@Nullable TileEntity adjacentTileEntity) {
|
||||
if (adjacentTileEntity instanceof IPartHost) {
|
||||
final IPart p = ((IPartHost) adjacentTileEntity).getPart(part.getSide());
|
||||
return p != null && p.getClass() == part.getClass();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private TileEntity getHostTileEntity() {
|
||||
IPartHost host = part.getHost();
|
||||
if (host != null) {
|
||||
return host.getTile();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,15 +18,10 @@
|
||||
|
||||
package appeng.parts.p2p;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Deque;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -37,18 +32,18 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.api.parts.IPartModel;
|
||||
import appeng.items.parts.PartModels;
|
||||
import appeng.me.GridAccessException;
|
||||
|
||||
public class FluidP2PTunnelPart extends P2PTunnelPart<FluidP2PTunnelPart> implements IFluidHandler {
|
||||
public class FluidP2PTunnelPart extends P2PTunnelPart<FluidP2PTunnelPart> {
|
||||
|
||||
private static final P2PModels MODELS = new P2PModels("part/p2p/p2p_tunnel_fluids");
|
||||
private static final IFluidHandler NULL_FLUID_HANDLER = new NullFluidHandler();
|
||||
|
||||
private static final ThreadLocal<Deque<FluidP2PTunnelPart>> DEPTH = new ThreadLocal<>();;
|
||||
|
||||
private LazyOptional<IFluidHandler> cachedTank;
|
||||
private int tmpUsed;
|
||||
private final IFluidHandler inputHandler = new InputFluidHandler();
|
||||
private final IFluidHandler outputHandler = new OutputFluidHandler();
|
||||
|
||||
public FluidP2PTunnelPart(final ItemStack is) {
|
||||
super(is);
|
||||
@@ -65,13 +60,10 @@ public class FluidP2PTunnelPart extends P2PTunnelPart<FluidP2PTunnelPart> implem
|
||||
|
||||
@Override
|
||||
public void onTunnelNetworkChange() {
|
||||
this.cachedTank = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged(IBlockReader w, BlockPos pos, BlockPos neighbor) {
|
||||
this.cachedTank = null;
|
||||
|
||||
if (this.isOutput()) {
|
||||
final FluidP2PTunnelPart in = this.getInput();
|
||||
if (in != null) {
|
||||
@@ -84,7 +76,10 @@ public class FluidP2PTunnelPart extends P2PTunnelPart<FluidP2PTunnelPart> implem
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> capabilityClass) {
|
||||
if (capabilityClass == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
|
||||
return (LazyOptional<T>) LazyOptional.of(() -> this);
|
||||
if (this.isOutput()) {
|
||||
return (LazyOptional<T>) LazyOptional.of(() -> this.outputHandler);
|
||||
}
|
||||
return (LazyOptional<T>) LazyOptional.of(() -> this.inputHandler);
|
||||
}
|
||||
|
||||
return super.getCapability(capabilityClass);
|
||||
@@ -95,168 +90,173 @@ public class FluidP2PTunnelPart extends P2PTunnelPart<FluidP2PTunnelPart> implem
|
||||
return MODELS.getModel(this.isPowered(), this.isActive());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTanks() {
|
||||
return 0;
|
||||
}
|
||||
private IFluidHandler getAttachedFluidHandler() {
|
||||
LazyOptional<IFluidHandler> fluidHandler = LazyOptional.empty();
|
||||
if (this.isActive()) {
|
||||
final TileEntity self = this.getTile();
|
||||
final TileEntity te = self.getWorld().getTileEntity(self.getPos().offset(this.getSide().getFacing()));
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public FluidStack getFluidInTank(int tank) {
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTankCapacity(int tank) {
|
||||
return 1000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFluidValid(int tank, @Nonnull FluidStack stack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(FluidStack resource, FluidAction action) {
|
||||
|
||||
final Deque<FluidP2PTunnelPart> stack = this.getDepth();
|
||||
|
||||
for (final FluidP2PTunnelPart t : stack) {
|
||||
if (t == this) {
|
||||
return 0;
|
||||
if (te != null) {
|
||||
fluidHandler = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY,
|
||||
this.getSide().getOpposite().getFacing());
|
||||
}
|
||||
}
|
||||
return fluidHandler.orElse(NULL_FLUID_HANDLER);
|
||||
}
|
||||
|
||||
stack.push(this);
|
||||
private class InputFluidHandler implements IFluidHandler {
|
||||
|
||||
final List<FluidP2PTunnelPart> list = this.getOutputs(resource.getFluid());
|
||||
int requestTotal = 0;
|
||||
|
||||
Iterator<FluidP2PTunnelPart> i = list.iterator();
|
||||
|
||||
while (i.hasNext()) {
|
||||
final FluidP2PTunnelPart l = i.next();
|
||||
final IFluidHandler tank = l.getTarget().orElse(null);
|
||||
if (tank != null) {
|
||||
l.tmpUsed = tank.fill(resource.copy(), FluidAction.SIMULATE);
|
||||
} else {
|
||||
l.tmpUsed = 0;
|
||||
}
|
||||
|
||||
if (l.tmpUsed <= 0) {
|
||||
i.remove();
|
||||
} else {
|
||||
requestTotal += l.tmpUsed;
|
||||
}
|
||||
@Override
|
||||
public int getTanks() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (requestTotal <= 0) {
|
||||
if (stack.pop() != this) {
|
||||
throw new IllegalStateException("Invalid Recursion detected.");
|
||||
@Override
|
||||
@Nonnull
|
||||
public FluidStack getFluidInTank(int tank) {
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTankCapacity(int tank) {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFluidValid(int tank, @Nonnull FluidStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(FluidStack resource, FluidAction action) {
|
||||
int total = 0;
|
||||
|
||||
try {
|
||||
final int outputTunnels = FluidP2PTunnelPart.this.getOutputs().size();
|
||||
final int amount = resource.getAmount();
|
||||
|
||||
if (outputTunnels == 0 || amount == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
final int amountPerOutput = Math.max(1, amount / outputTunnels);
|
||||
int overflow = amountPerOutput == 0 ? amount : amount % amountPerOutput;
|
||||
|
||||
for (FluidP2PTunnelPart target : FluidP2PTunnelPart.this.getOutputs()) {
|
||||
final IFluidHandler output = target.getAttachedFluidHandler();
|
||||
final int toSend = amountPerOutput + overflow;
|
||||
final FluidStack fillWithFluidStack = resource.copy();
|
||||
fillWithFluidStack.setAmount(toSend);
|
||||
|
||||
final int received = output.fill(fillWithFluidStack, action);
|
||||
|
||||
overflow = toSend - received;
|
||||
total += received;
|
||||
}
|
||||
|
||||
if (action == FluidAction.EXECUTE) {
|
||||
FluidP2PTunnelPart.this.queueTunnelDrain(PowerUnits.RF, total);
|
||||
}
|
||||
} catch (GridAccessException ignored) {
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public FluidStack drain(FluidStack resource, FluidAction action) {
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public FluidStack drain(int maxDrain, FluidAction action) {
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class OutputFluidHandler implements IFluidHandler {
|
||||
|
||||
@Override
|
||||
public int getTanks() {
|
||||
return FluidP2PTunnelPart.this.getAttachedFluidHandler().getTanks();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public FluidStack getFluidInTank(int tank) {
|
||||
return FluidP2PTunnelPart.this.getAttachedFluidHandler().getFluidInTank(tank);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTankCapacity(int tank) {
|
||||
return FluidP2PTunnelPart.this.getAttachedFluidHandler().getTankCapacity(tank);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFluidValid(int tank, @Nonnull FluidStack stack) {
|
||||
return FluidP2PTunnelPart.this.getAttachedFluidHandler().isFluidValid(tank, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(FluidStack resource, FluidAction action) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (action != FluidAction.EXECUTE) {
|
||||
if (stack.pop() != this) {
|
||||
throw new IllegalStateException("Invalid Recursion detected.");
|
||||
}
|
||||
|
||||
return Math.min(resource.getAmount(), requestTotal);
|
||||
@Override
|
||||
@Nonnull
|
||||
public FluidStack drain(FluidStack resource, FluidAction action) {
|
||||
return FluidP2PTunnelPart.this.getAttachedFluidHandler().drain(resource, action);
|
||||
}
|
||||
|
||||
int available = resource.getAmount();
|
||||
|
||||
i = list.iterator();
|
||||
int used = 0;
|
||||
|
||||
while (i.hasNext() && available > 0) {
|
||||
final FluidP2PTunnelPart l = i.next();
|
||||
|
||||
final FluidStack insert = resource.copy();
|
||||
insert.setAmount((int) Math.ceil(insert.getAmount() * ((double) l.tmpUsed / (double) requestTotal)));
|
||||
if (insert.getAmount() > available) {
|
||||
insert.setAmount(available);
|
||||
}
|
||||
|
||||
final IFluidHandler tank = l.getTarget().orElse(null);
|
||||
if (tank != null) {
|
||||
l.tmpUsed = tank.fill(insert.copy(), action);
|
||||
} else {
|
||||
l.tmpUsed = 0;
|
||||
}
|
||||
|
||||
available -= insert.getAmount();
|
||||
used += l.tmpUsed;
|
||||
@Override
|
||||
@Nonnull
|
||||
public FluidStack drain(int maxDrain, FluidAction action) {
|
||||
return FluidP2PTunnelPart.this.getAttachedFluidHandler().drain(maxDrain, action);
|
||||
}
|
||||
|
||||
if (stack.pop() != this) {
|
||||
throw new IllegalStateException("Invalid Recursion detected.");
|
||||
}
|
||||
|
||||
return used;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public FluidStack drain(FluidStack resource, FluidAction action) {
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
private static class NullFluidHandler implements IFluidHandler {
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public FluidStack drain(int maxDrain, FluidAction action) {
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
|
||||
private Deque<FluidP2PTunnelPart> getDepth() {
|
||||
Deque<FluidP2PTunnelPart> s = DEPTH.get();
|
||||
|
||||
if (s == null) {
|
||||
DEPTH.set(s = new ArrayDeque<>());
|
||||
@Override
|
||||
public int getTanks() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
private List<FluidP2PTunnelPart> getOutputs(final Fluid input) {
|
||||
final List<FluidP2PTunnelPart> outs = new ArrayList<>();
|
||||
|
||||
try {
|
||||
for (final FluidP2PTunnelPart l : this.getOutputs()) {
|
||||
final IFluidHandler handler = l.getTarget().orElse(null);
|
||||
|
||||
if (handler != null) {
|
||||
outs.add(l);
|
||||
}
|
||||
}
|
||||
} catch (final GridAccessException e) {
|
||||
// :P
|
||||
@Override
|
||||
@Nonnull
|
||||
public FluidStack getFluidInTank(int tank) {
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
|
||||
return outs;
|
||||
}
|
||||
|
||||
private LazyOptional<IFluidHandler> getTarget() {
|
||||
if (!this.getProxy().isActive()) {
|
||||
return null;
|
||||
@Override
|
||||
public int getTankCapacity(int tank) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (this.cachedTank != null) {
|
||||
return this.cachedTank;
|
||||
@Override
|
||||
public boolean isFluidValid(int tank, @Nonnull FluidStack stack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final TileEntity te = this.getTile().getWorld()
|
||||
.getTileEntity(this.getTile().getPos().offset(this.getSide().getFacing()));
|
||||
|
||||
if (te != null && te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY,
|
||||
this.getSide().getFacing().getOpposite()).isPresent()) {
|
||||
return this.cachedTank = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY,
|
||||
this.getSide().getFacing().getOpposite());
|
||||
@Override
|
||||
public int fill(FluidStack resource, FluidAction action) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return null;
|
||||
@Override
|
||||
@Nonnull
|
||||
public FluidStack drain(FluidStack resource, FluidAction action) {
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public FluidStack drain(int maxDrain, FluidAction action) {
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,9 +14,13 @@ import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
|
||||
public class GrinderRecipe implements IRecipe<IInventory> {
|
||||
|
||||
public static IRecipeType<GrinderRecipe> TYPE;
|
||||
public static final ResourceLocation TYPE_ID = new ResourceLocation(AppEng.MOD_ID, "grinder");
|
||||
|
||||
public static final IRecipeType<GrinderRecipe> TYPE = IRecipeType.register(TYPE_ID.toString());
|
||||
|
||||
private final ResourceLocation id;
|
||||
private final String group;
|
||||
|
||||
@@ -29,7 +29,7 @@ public class GrinderRecipeSerializer extends ForgeRegistryEntry<IRecipeSerialize
|
||||
public static final GrinderRecipeSerializer INSTANCE = new GrinderRecipeSerializer();
|
||||
|
||||
static {
|
||||
INSTANCE.setRegistryName(AppEng.MOD_ID, "grinder");
|
||||
INSTANCE.setRegistryName(GrinderRecipe.TYPE_ID);
|
||||
}
|
||||
|
||||
private GrinderRecipeSerializer() {
|
||||
|
||||
@@ -11,10 +11,13 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.features.InscriberProcessType;
|
||||
import appeng.core.AppEng;
|
||||
|
||||
public class InscriberRecipe implements IRecipe<IInventory> {
|
||||
|
||||
public static IRecipeType<InscriberRecipe> TYPE;
|
||||
public static final ResourceLocation TYPE_ID = new ResourceLocation(AppEng.MOD_ID, "inscriber");
|
||||
|
||||
public static final IRecipeType<InscriberRecipe> TYPE = IRecipeType.register(TYPE_ID.toString());
|
||||
|
||||
private final ResourceLocation id;
|
||||
private final String group;
|
||||
|
||||
@@ -23,7 +23,7 @@ public class InscriberRecipeSerializer extends ForgeRegistryEntry<IRecipeSeriali
|
||||
public static final InscriberRecipeSerializer INSTANCE = new InscriberRecipeSerializer();
|
||||
|
||||
static {
|
||||
INSTANCE.setRegistryName(AppEng.MOD_ID, "inscriber");
|
||||
INSTANCE.setRegistryName(InscriberRecipe.TYPE_ID);
|
||||
}
|
||||
|
||||
private InscriberRecipeSerializer() {
|
||||
|
||||
@@ -310,7 +310,7 @@ public class CableBusTileEntity extends AEBaseTileEntity implements AEMultiTile
|
||||
IPart part = this.getPart(partLocation);
|
||||
LazyOptional<T> result = part == null ? LazyOptional.empty() : part.getCapability(capabilityClass);
|
||||
|
||||
if (result != null) {
|
||||
if (result.isPresent()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user