mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 23:28:35 +01:00
Drop it like its hot... ill show myself out thank you...
This commit is contained in:
parent
9bb1105c7c
commit
327fdc5c3b
5 changed files with 24 additions and 10 deletions
|
@ -22,21 +22,29 @@ import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class BlockDropper extends FullyDirectionalBlock.Container {
|
public class BlockDropper extends FullyDirectionalBlock.Container {
|
||||||
|
|
||||||
public BlockDropper() {
|
public BlockDropper() {
|
||||||
super(ActuallyBlocks.defaultPickProps(0));
|
super(ActuallyBlocks.defaultPickProps(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Override
|
@Override
|
||||||
public TileEntity newBlockEntity(IBlockReader worldIn) {
|
public boolean hasTileEntity(BlockState state) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
||||||
return new TileEntityDropper();
|
return new TileEntityDropper();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||||
if (this.tryToggleRedstone(world, pos, player)) {
|
if (this.tryToggleRedstone(world, pos, player)) {
|
||||||
return ActionResultType.PASS;
|
return ActionResultType.CONSUME;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.openGui(world, player, pos, TileEntityDropper.class);
|
return this.openGui(world, player, pos, TileEntityDropper.class);
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks.base;
|
package de.ellpeck.actuallyadditions.mod.blocks.base;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
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.config.ConfigValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityInventoryBase;
|
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) {
|
public boolean tryToggleRedstone(World world, BlockPos pos, PlayerEntity player) {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (StackUtil.isValid(stack) && stack.getItem() == ConfigValues.itemRedstoneTorchConfigurator) {
|
if (stack.getItem() == CommonConfig.Other.redstoneConfigureItem) {
|
||||||
TileEntity tile = world.getBlockEntity(pos);
|
TileEntity tile = world.getBlockEntity(pos);
|
||||||
if (tile instanceof TileEntityBase) {
|
if (tile instanceof TileEntityBase) {
|
||||||
TileEntityBase base = (TileEntityBase) tile;
|
TileEntityBase base = (TileEntityBase) tile;
|
||||||
|
@ -155,6 +156,8 @@ public abstract class BlockContainerBase extends Block {
|
||||||
if (base.respondsToPulses()) {
|
if (base.respondsToPulses()) {
|
||||||
// TODO: [port] eval what this does? :D
|
// TODO: [port] eval what this does? :D
|
||||||
// world.scheduleUpdate(pos, this, this.tickRate(world));
|
// world.scheduleUpdate(pos, this, this.tickRate(world));
|
||||||
|
// Who knows -Flanks
|
||||||
|
base.activateOnPulse();
|
||||||
}
|
}
|
||||||
base.setRedstonePowered(true);
|
base.setRedstonePowered(true);
|
||||||
} else if (!powered && wasPowered) {
|
} else if (!powered && wasPowered) {
|
||||||
|
|
|
@ -191,16 +191,16 @@ public class ClientEvents {
|
||||||
if (tileHit instanceof TileEntityBase) {
|
if (tileHit instanceof TileEntityBase) {
|
||||||
TileEntityBase base = (TileEntityBase) tileHit;
|
TileEntityBase base = (TileEntityBase) tileHit;
|
||||||
if (base.isRedstoneToggle()) {
|
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"
|
? "pulse"
|
||||||
: "deactivation")) + TextFormatting.RESET);
|
: "deactivation")) + TextFormatting.RESET);
|
||||||
font.drawShadow(event.getMatrixStack(), strg, event.getWindow().getGuiScaledWidth() / 2f + 5, event.getWindow().getGuiScaledHeight() / 2f + 5, StringUtil.DECIMAL_COLOR_WHITE);
|
font.drawShadow(event.getMatrixStack(), strg, event.getWindow().getGuiScaledWidth() / 2f + 5, event.getWindow().getGuiScaledHeight() / 2f + 5, StringUtil.DECIMAL_COLOR_WHITE);
|
||||||
|
|
||||||
String expl;
|
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");
|
expl = TextFormatting.GREEN + StringUtil.localize("info." + ActuallyAdditions.MODID + ".redstoneMode.validItem");
|
||||||
} else {
|
} 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);
|
font.drawShadow(event.getMatrixStack(), expl, event.getWindow().getGuiScaledWidth() / 2f + 5, event.getWindow().getGuiScaledHeight() / 2f + 15, StringUtil.DECIMAL_COLOR_WHITE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,8 +38,10 @@ public class GuiDropper extends AAScreen<ContainerDropper> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderLabels(@Nonnull MatrixStack matrices, int x, int y) {
|
protected void init() {
|
||||||
AssetUtil.displayNameString(matrices, this.font, this.imageWidth, -10, this.dropper);
|
super.init();
|
||||||
|
titleLabelX = (int) (imageWidth / 2.0f - font.width(title) / 2.0f);
|
||||||
|
titleLabelY = -10;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -27,6 +27,7 @@ import net.minecraft.util.text.StringTextComponent;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase.NBTType;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase.NBTType;
|
||||||
|
import net.minecraft.util.text.TranslationTextComponent;
|
||||||
|
|
||||||
public class TileEntityDropper extends TileEntityInventoryBase implements INamedContainerProvider {
|
public class TileEntityDropper extends TileEntityInventoryBase implements INamedContainerProvider {
|
||||||
|
|
||||||
|
@ -106,7 +107,7 @@ public class TileEntityDropper extends TileEntityInventoryBase implements INamed
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ITextComponent getDisplayName() {
|
public ITextComponent getDisplayName() {
|
||||||
return StringTextComponent.EMPTY;
|
return new TranslationTextComponent("container.actuallyadditions.dropper");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|
Loading…
Reference in a new issue