Compare commits

..

3 commits

Author SHA1 Message Date
Flanks255
ce972eb1f3 breaker breaks. 2022-04-03 19:12:40 -05:00
Flanks255
30e8137c04 placer works... the breaker tho... 2022-04-03 15:18:46 -05:00
Flanks255
327fdc5c3b Drop it like its hot... ill show myself out thank you... 2022-04-03 13:36:07 -05:00
9 changed files with 58 additions and 22 deletions

View file

@ -34,9 +34,14 @@ public class BlockBreaker extends FullyDirectionalBlock.Container {
this.isPlacer = isPlacer;
}
@Override
public boolean hasTileEntity(BlockState state) {
return true;
}
@Nullable
//@Override
public TileEntity newBlockEntity(IBlockReader world) {
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return this.isPlacer
? new TileEntityPlacer()
: new TileEntityBreaker();
@ -45,7 +50,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.PASS;
return ActionResultType.CONSUME;
}
return this.openGui(world, player, pos, TileEntityBreaker.class);

View file

@ -22,21 +22,29 @@ 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 TileEntity newBlockEntity(IBlockReader worldIn) {
@Override
public boolean hasTileEntity(BlockState state) {
return true;
}
@Nullable
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
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.PASS;
return ActionResultType.CONSUME;
}
return this.openGui(world, player, pos, TileEntityDropper.class);

View file

@ -11,6 +11,7 @@
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;
@ -91,7 +92,7 @@ public abstract class BlockContainerBase extends Block {
public boolean tryToggleRedstone(World world, BlockPos pos, PlayerEntity player) {
ItemStack stack = player.getMainHandItem();
if (StackUtil.isValid(stack) && stack.getItem() == ConfigValues.itemRedstoneTorchConfigurator) {
if (stack.getItem() == CommonConfig.Other.redstoneConfigureItem) {
TileEntity tile = world.getBlockEntity(pos);
if (tile instanceof TileEntityBase) {
TileEntityBase base = (TileEntityBase) tile;
@ -131,7 +132,7 @@ public abstract class BlockContainerBase extends Block {
}
}
@Override
@Override //TODO do we need this?
public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) {
this.neighborsChangedCustom(worldIn, pos);
}
@ -139,7 +140,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) {
if (world instanceof World) { //TODO what?
this.neighborsChangedCustom((World) world, pos);
}
}
@ -155,6 +156,8 @@ 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) {

View file

@ -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.name"), TextFormatting.DARK_RED + StringUtil.localize("info." + ActuallyAdditions.MODID + ".redstoneMode." + (base.isPulseMode
String strg = String.format("%s: %s", StringUtil.localize("info." + ActuallyAdditions.MODID + ".redstoneMode"), 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() == ConfigValues.itemRedstoneTorchConfigurator) {
if (StackUtil.isValid(stack) && stack.getItem() == CommonConfig.Other.redstoneConfigureItem.asItem()) {
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.getDescriptionId() + ".name"));
expl = TextFormatting.GRAY.toString() + TextFormatting.ITALIC + StringUtil.localizeFormatted("info." + ActuallyAdditions.MODID + ".redstoneMode.invalidItem", StringUtil.localize(CommonConfig.Other.redstoneConfigureItem.asItem().getDescriptionId()));
}
font.drawShadow(event.getMatrixStack(), expl, event.getWindow().getGuiScaledWidth() / 2f + 5, event.getWindow().getGuiScaledHeight() / 2f + 15, StringUtil.DECIMAL_COLOR_WHITE);
}

View file

@ -15,6 +15,7 @@ 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;
@ -36,6 +37,13 @@ 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);

View file

@ -38,8 +38,10 @@ public class GuiDropper extends AAScreen<ContainerDropper> {
}
@Override
public void renderLabels(@Nonnull MatrixStack matrices, int x, int y) {
AssetUtil.displayNameString(matrices, this.font, this.imageWidth, -10, this.dropper);
protected void init() {
super.init();
titleLabelX = (int) (imageWidth / 2.0f - font.width(title) / 2.0f);
titleLabelY = -10;
}
@Override

View file

@ -13,6 +13,7 @@ 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;
@ -29,9 +30,13 @@ 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;
@ -97,9 +102,11 @@ 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));
float chance = WorldUtil.fireFakeHarvestEventsForDropChance(this, drops, this.level, breakCoords);
if (chance > 0 && this.level.random.nextFloat() <= chance) {
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
if (StackUtil.canAddAll(this.inv, drops, false)) {
this.level.destroyBlock(breakCoords, false);
StackUtil.addAll(this.inv, drops, false);
@ -125,9 +132,10 @@ public class TileEntityBreaker extends TileEntityInventoryBase implements INamed
this.doWork();
}
@Nonnull
@Override
public ITextComponent getDisplayName() {
return StringTextComponent.EMPTY;
return new TranslationTextComponent(isPlacer ? "container.actuallyadditions.placer" : "container.actuallyadditions.breaker");
}
@Nullable

View file

@ -27,6 +27,7 @@ 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 {
@ -106,7 +107,7 @@ public class TileEntityDropper extends TileEntityInventoryBase implements INamed
@Override
public ITextComponent getDisplayName() {
return StringTextComponent.EMPTY;
return new TranslationTextComponent("container.actuallyadditions.dropper");
}
@Nullable

View file

@ -196,11 +196,12 @@ 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());
//fake.gameMode.useItemOn(fake, world, fake.getMainHandItem(), Hand.MAIN_HAND, offsetPos, side.getOpposite(), 0.5F, 0.5F, 0.5F); //TODO
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);
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);