mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-25 16:38:33 +01:00
Compare commits
No commits in common. "ce972eb1f3bd0c9fd745e06619dca545a910cd9e" and "9bb1105c7c616ce13186a53dc907c79a68a05aa8" have entirely different histories.
ce972eb1f3
...
9bb1105c7c
9 changed files with 22 additions and 58 deletions
|
@ -34,14 +34,9 @@ public class BlockBreaker extends FullyDirectionalBlock.Container {
|
|||
this.isPlacer = isPlacer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
||||
//@Override
|
||||
public TileEntity newBlockEntity(IBlockReader world) {
|
||||
return this.isPlacer
|
||||
? new TileEntityPlacer()
|
||||
: new TileEntityBreaker();
|
||||
|
@ -50,7 +45,7 @@ public class BlockBreaker extends FullyDirectionalBlock.Container {
|
|||
@Override
|
||||
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
|
||||
if (this.tryToggleRedstone(world, pos, player)) {
|
||||
return ActionResultType.CONSUME;
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
return this.openGui(world, player, pos, TileEntityBreaker.class);
|
||||
|
|
|
@ -22,29 +22,21 @@ import net.minecraft.util.math.BlockRayTraceResult;
|
|||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BlockDropper extends FullyDirectionalBlock.Container {
|
||||
|
||||
public BlockDropper() {
|
||||
super(ActuallyBlocks.defaultPickProps(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
||||
//@Override
|
||||
public TileEntity newBlockEntity(IBlockReader worldIn) {
|
||||
return new TileEntityDropper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||
if (this.tryToggleRedstone(world, pos, player)) {
|
||||
return ActionResultType.CONSUME;
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
return this.openGui(world, player, pos, TileEntityDropper.class);
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
package de.ellpeck.actuallyadditions.mod.blocks.base;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
|
||||
import de.ellpeck.actuallyadditions.mod.config.ConfigValues;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityInventoryBase;
|
||||
|
@ -92,7 +91,7 @@ public abstract class BlockContainerBase extends Block {
|
|||
|
||||
public boolean tryToggleRedstone(World world, BlockPos pos, PlayerEntity player) {
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
if (stack.getItem() == CommonConfig.Other.redstoneConfigureItem) {
|
||||
if (StackUtil.isValid(stack) && stack.getItem() == ConfigValues.itemRedstoneTorchConfigurator) {
|
||||
TileEntity tile = world.getBlockEntity(pos);
|
||||
if (tile instanceof TileEntityBase) {
|
||||
TileEntityBase base = (TileEntityBase) tile;
|
||||
|
@ -132,7 +131,7 @@ public abstract class BlockContainerBase extends Block {
|
|||
}
|
||||
}
|
||||
|
||||
@Override //TODO do we need this?
|
||||
@Override
|
||||
public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) {
|
||||
this.neighborsChangedCustom(worldIn, pos);
|
||||
}
|
||||
|
@ -140,7 +139,7 @@ public abstract class BlockContainerBase extends Block {
|
|||
@Override
|
||||
public void onNeighborChange(BlockState state, IWorldReader world, BlockPos pos, BlockPos neighbor) {
|
||||
super.onNeighborChange(state, world, pos, neighbor);
|
||||
if (world instanceof World) { //TODO what?
|
||||
if (world instanceof World) {
|
||||
this.neighborsChangedCustom((World) world, pos);
|
||||
}
|
||||
}
|
||||
|
@ -156,8 +155,6 @@ public abstract class BlockContainerBase extends Block {
|
|||
if (base.respondsToPulses()) {
|
||||
// TODO: [port] eval what this does? :D
|
||||
// world.scheduleUpdate(pos, this, this.tickRate(world));
|
||||
// Who knows -Flanks
|
||||
base.activateOnPulse();
|
||||
}
|
||||
base.setRedstonePowered(true);
|
||||
} else if (!powered && wasPowered) {
|
||||
|
|
|
@ -191,16 +191,16 @@ public class ClientEvents {
|
|||
if (tileHit instanceof TileEntityBase) {
|
||||
TileEntityBase base = (TileEntityBase) tileHit;
|
||||
if (base.isRedstoneToggle()) {
|
||||
String strg = String.format("%s: %s", StringUtil.localize("info." + ActuallyAdditions.MODID + ".redstoneMode"), TextFormatting.DARK_RED + StringUtil.localize("info." + ActuallyAdditions.MODID + ".redstoneMode." + (base.isPulseMode
|
||||
String strg = String.format("%s: %s", StringUtil.localize("info." + ActuallyAdditions.MODID + ".redstoneMode.name"), TextFormatting.DARK_RED + StringUtil.localize("info." + ActuallyAdditions.MODID + ".redstoneMode." + (base.isPulseMode
|
||||
? "pulse"
|
||||
: "deactivation")) + TextFormatting.RESET);
|
||||
font.drawShadow(event.getMatrixStack(), strg, event.getWindow().getGuiScaledWidth() / 2f + 5, event.getWindow().getGuiScaledHeight() / 2f + 5, StringUtil.DECIMAL_COLOR_WHITE);
|
||||
|
||||
String expl;
|
||||
if (StackUtil.isValid(stack) && stack.getItem() == CommonConfig.Other.redstoneConfigureItem.asItem()) {
|
||||
if (StackUtil.isValid(stack) && stack.getItem() == ConfigValues.itemRedstoneTorchConfigurator) {
|
||||
expl = TextFormatting.GREEN + StringUtil.localize("info." + ActuallyAdditions.MODID + ".redstoneMode.validItem");
|
||||
} else {
|
||||
expl = TextFormatting.GRAY.toString() + TextFormatting.ITALIC + StringUtil.localizeFormatted("info." + ActuallyAdditions.MODID + ".redstoneMode.invalidItem", StringUtil.localize(CommonConfig.Other.redstoneConfigureItem.asItem().getDescriptionId()));
|
||||
expl = TextFormatting.GRAY.toString() + TextFormatting.ITALIC + StringUtil.localizeFormatted("info." + ActuallyAdditions.MODID + ".redstoneMode.invalidItem", StringUtil.localize(CommonConfig.Other.redstoneConfigureItem.getDescriptionId() + ".name"));
|
||||
}
|
||||
font.drawShadow(event.getMatrixStack(), expl, event.getWindow().getGuiScaledWidth() / 2f + 5, event.getWindow().getGuiScaledHeight() / 2f + 15, StringUtil.DECIMAL_COLOR_WHITE);
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
|||
import de.ellpeck.actuallyadditions.mod.inventory.ContainerBreaker;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBreaker;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
@ -37,13 +36,6 @@ public class GuiBreaker extends AAScreen<ContainerBreaker> {
|
|||
this.imageHeight = 93 + 86;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Minecraft pMinecraft, int pWidth, int pHeight) {
|
||||
super.init(pMinecraft, pWidth, pHeight);
|
||||
titleLabelX = (int) (imageWidth / 2.0f - font.width(title) / 2.0f);
|
||||
titleLabelY = -10;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBg(@Nonnull MatrixStack matrices, float partialTicks, int x, int y) {
|
||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
|
|
@ -38,10 +38,8 @@ public class GuiDropper extends AAScreen<ContainerDropper> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
super.init();
|
||||
titleLabelX = (int) (imageWidth / 2.0f - font.width(title) / 2.0f);
|
||||
titleLabelY = -10;
|
||||
public void renderLabels(@Nonnull MatrixStack matrices, int x, int y) {
|
||||
AssetUtil.displayNameString(matrices, this.font, this.imageWidth, -10, this.dropper);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -13,7 +13,6 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
|||
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.ContainerBreaker;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
||||
import de.ellpeck.actuallyadditions.mod.util.NetHandlerSpaghettiServer;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -30,13 +29,9 @@ import net.minecraft.util.Direction;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -102,11 +97,9 @@ public class TileEntityBreaker extends TileEntityInventoryBase implements INamed
|
|||
|
||||
if (!this.isPlacer && blockToBreak != Blocks.AIR && !(blockToBreak instanceof IFluidBlock) && stateToBreak.getDestroySpeed(this.level, breakCoords) >= 0.0F) {
|
||||
List<ItemStack> drops = Block.getDrops(stateToBreak, (ServerWorld) this.level, breakCoords, this.level.getBlockEntity(breakCoords));
|
||||
FakePlayer fake = FakePlayerFactory.getMinecraft((ServerWorld) this.level);
|
||||
if (fake.connection == null) {
|
||||
fake.connection = new NetHandlerSpaghettiServer(fake);
|
||||
}
|
||||
if (stateToBreak.canHarvestBlock(this.level, breakCoords, fake)) { //TODO might double check this is right mikey
|
||||
float chance = WorldUtil.fireFakeHarvestEventsForDropChance(this, drops, this.level, breakCoords);
|
||||
|
||||
if (chance > 0 && this.level.random.nextFloat() <= chance) {
|
||||
if (StackUtil.canAddAll(this.inv, drops, false)) {
|
||||
this.level.destroyBlock(breakCoords, false);
|
||||
StackUtil.addAll(this.inv, drops, false);
|
||||
|
@ -132,10 +125,9 @@ public class TileEntityBreaker extends TileEntityInventoryBase implements INamed
|
|||
this.doWork();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ITextComponent getDisplayName() {
|
||||
return new TranslationTextComponent(isPlacer ? "container.actuallyadditions.placer" : "container.actuallyadditions.breaker");
|
||||
return StringTextComponent.EMPTY;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
|
|
@ -27,7 +27,6 @@ import net.minecraft.util.text.StringTextComponent;
|
|||
import javax.annotation.Nullable;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase.NBTType;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
|
||||
public class TileEntityDropper extends TileEntityInventoryBase implements INamedContainerProvider {
|
||||
|
||||
|
@ -107,7 +106,7 @@ public class TileEntityDropper extends TileEntityInventoryBase implements INamed
|
|||
|
||||
@Override
|
||||
public ITextComponent getDisplayName() {
|
||||
return new TranslationTextComponent("container.actuallyadditions.dropper");
|
||||
return StringTextComponent.EMPTY;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
|
|
@ -196,12 +196,11 @@ public final class WorldUtil {
|
|||
if (fake.connection == null) {
|
||||
fake.connection = new NetHandlerSpaghettiServer(fake);
|
||||
}
|
||||
//ItemStack heldBefore = fake.getMainHandItem();
|
||||
ItemStack heldBefore = fake.getMainHandItem();
|
||||
setHandItemWithoutAnnoyingSound(fake, Hand.MAIN_HAND, stack.copy());
|
||||
BlockRayTraceResult ray = new BlockRayTraceResult(new Vector3d(0.5, 0.5, 0.5), side.getOpposite(), offsetPos, true);
|
||||
fake.gameMode.useItemOn(fake, world, fake.getMainHandItem(), Hand.MAIN_HAND, ray);
|
||||
//fake.gameMode.useItemOn(fake, world, fake.getMainHandItem(), Hand.MAIN_HAND, offsetPos, side.getOpposite(), 0.5F, 0.5F, 0.5F); //TODO
|
||||
ItemStack result = fake.getItemInHand(Hand.MAIN_HAND);
|
||||
//setHandItemWithoutAnnoyingSound(fake, Hand.MAIN_HAND, heldBefore);
|
||||
setHandItemWithoutAnnoyingSound(fake, Hand.MAIN_HAND, heldBefore);
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
ActuallyAdditions.LOGGER.error("Something that places Blocks at " + offsetPos.getX() + ", " + offsetPos.getY() + ", " + offsetPos.getZ() + " in World " + world.dimension() + " threw an Exception! Don't let that happen again!", e);
|
||||
|
|
Loading…
Reference in a new issue