Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More redstone components #914

Open
wants to merge 86 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 57 commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
fc376ca
Basic dispenser functionality
Creeperface01 Aug 11, 2019
ebd0365
Merge remote-tracking branch 'origin/master' into redstone
Creeperface01 Aug 11, 2019
538c819
Broken pistons implementation
Creeperface01 Aug 16, 2019
69ea148
fixed piston input power, plugin unknown dependency message
Creeperface01 Aug 18, 2019
079f47e
plugin unknown dependency message
Creeperface01 Aug 18, 2019
2aaa64d
fix build
Creeperface01 Aug 18, 2019
f608942
update
Creeperface01 Sep 17, 2019
e38921e
fixes
Creeperface01 Sep 18, 2019
4fc454d
update
Creeperface01 Oct 5, 2019
6318c0e
Fix slimeblocks
Creeperface01 Oct 12, 2019
55e12a1
Implement entity collision
Creeperface01 Oct 13, 2019
f2969ac
Dropper
Creeperface01 Oct 13, 2019
25b57ed
merge master
Creeperface01 Oct 13, 2019
c9d3a55
Bumb API version
Creeperface01 Oct 13, 2019
b0a1d5f
allow more digits in the API version
Creeperface01 Oct 15, 2019
717d44b
Add option to disable redstone
Creeperface01 Oct 16, 2019
b679e70
fix submodule
Creeperface01 Oct 20, 2019
38820ae
test
Creeperface01 Oct 20, 2019
3d7e846
test
Creeperface01 Oct 21, 2019
9004211
Fix submodule
Creeperface01 Oct 21, 2019
9a38c49
Fix duplication bug
Creeperface01 Oct 22, 2019
9ab951f
Fix dispenser duplication
Creeperface01 Oct 22, 2019
d323b52
Fix compatibility
Creeperface01 Oct 22, 2019
64de485
Prevent NPE
Creeperface01 Oct 22, 2019
bd2d2ba
Add BlockPistonEvent
Creeperface01 Oct 23, 2019
f1360be
Fix comparator updates
Creeperface01 Oct 24, 2019
23adeaa
Fix hopper disabled behavior
Creeperface01 Oct 24, 2019
4f2b31c
Fix default facing
Creeperface01 Oct 29, 2019
3a210f7
Add sounds and particles
Creeperface01 Oct 31, 2019
f2085eb
Merge remote-tracking branch 'origin/redstone' into redstone
Creeperface01 Oct 31, 2019
56c0840
Merge 1.13
Creeperface01 Nov 3, 2019
4923c51
Fix piston retracting
Creeperface01 Nov 3, 2019
ae01cd3
Merge remote-tracking branch 'origin/bedrock-1.13' into redstone
Creeperface01 Nov 23, 2019
3a96364
ops
Creeperface01 Nov 23, 2019
d02f415
Static access
Creeperface01 Nov 23, 2019
78e98f7
Fix palette
Creeperface01 Nov 24, 2019
405f23c
Merge remote-tracking branch 'remotes/origin/master' into redstone
Creeperface01 Nov 30, 2019
bd8f5bc
ops
Creeperface01 Nov 30, 2019
b9dd554
Remove debug message left by @Creeperface01 :)
SupremeMortal Nov 30, 2019
334fef0
Merge branch 'master' of https://github.com/NukkitX/Nukkit into redstone
SupremeMortal Nov 30, 2019
9511c34
Merge remote-tracking branch 'origin/redstone' into redstone
SupremeMortal Nov 30, 2019
ae2e7b9
Merge remote-tracking branch 'remotes/origin/master' into redstone
Creeperface01 Dec 9, 2019
d53a270
Merge remote-tracking branch 'origin/redstone' into redstone
Creeperface01 Dec 9, 2019
180fefe
Fix redstone wire placement
Creeperface01 Dec 9, 2019
7bab7c7
Fix block names
Creeperface01 Dec 9, 2019
a79a861
ops
Creeperface01 Dec 9, 2019
294d397
Bump protocol version to 389
SupremeMortal Dec 10, 2019
bb3aad2
Support 1.13 and 1.14
SupremeMortal Dec 10, 2019
eb68985
Merge branch 'master' of https://github.com/NukkitX/Nukkit into redstone
SupremeMortal Dec 10, 2019
f3ab3af
Merge remote-tracking branch 'remotes/origin/bedrock-1.14' into redstone
Creeperface01 Dec 11, 2019
66bf314
Merge remote-tracking branch 'origin/redstone' into redstone
Creeperface01 Dec 12, 2019
a488f71
Merge remote-tracking branch 'remotes/origin/master' into redstone
Creeperface01 Dec 13, 2019
288724c
Fix comparator immediate update
Creeperface01 Dec 15, 2019
8e8d63b
Fix block updates
Creeperface01 Dec 15, 2019
65d96c6
don't push extended pistons
Creeperface01 Dec 15, 2019
7f9086d
Fix pistons behavior
Creeperface01 Dec 21, 2019
02ac8a3
Merge remote-tracking branch 'remotes/origin/master' into redstone
Creeperface01 Dec 21, 2019
a6f99d5
Drop painting when pushed
Creeperface01 Dec 24, 2019
73fb1a2
Merge remote-tracking branch 'remotes/origin/master' into redstone
Creeperface01 Dec 30, 2019
5be10a9
Don't create new BlockEntityPiston instance directly
Creeperface01 Dec 30, 2019
bd3efa1
Fix buttons
Creeperface01 Jan 2, 2020
e2407f2
Merge remote-tracking branch 'origin/redstone' into redstone
Creeperface01 Jan 2, 2020
d7de1ef
Fixed piston bug
Creeperface01 Jan 2, 2020
8a3c56e
Fix piston placement
Creeperface01 Jan 2, 2020
6211594
Merge remote-tracking branch 'remotes/origin/master' into redstone
Creeperface01 Jan 4, 2020
d46a4d7
Don't use player instance in async event
Creeperface01 Jan 4, 2020
d72138b
merge
Creeperface01 Jan 9, 2020
d5193af
Merge branch 'master' of https://github.com/NukkitX/Nukkit into redstone
SupremeMortal Jan 10, 2020
aa12ad7
Merge remote-tracking branch 'remotes/origin/master' into redstone
Creeperface01 Jan 11, 2020
5931d91
Fix redstone torch and piston update
Creeperface01 Jan 12, 2020
a9e676d
Merge branches 'master' and 'redstone' of https://github.com/NukkitX/…
SupremeMortal Feb 12, 2020
ad292d8
Merge branch 'master' of https://github.com/NukkitX/Nukkit into redstone
SupremeMortal Mar 16, 2020
066244e
Merge branches 'master' and 'redstone' of https://github.com/NukkitX/…
SupremeMortal Apr 5, 2020
925f472
Merge branch 'master' of https://github.com/NukkitX/Nukkit into redstone
SupremeMortal Apr 5, 2020
714317c
Merge branch 'master' of https://github.com/NukkitX/Nukkit into redstone
SupremeMortal Apr 6, 2020
bfcfde9
Merge branch 'master' of https://github.com/NukkitX/Nukkit into redstone
SupremeMortal Apr 16, 2020
2cdd822
Merge branch 'master' of https://github.com/NukkitX/Nukkit into redstone
SupremeMortal Apr 16, 2020
4f24a4e
Merge branch 'master' of https://github.com/NukkitX/Nukkit into redstone
SupremeMortal Apr 29, 2020
fa2db54
Merge branch 'master' of https://github.com/NukkitX/Nukkit into redstone
SupremeMortal Apr 30, 2020
8344d9f
[Redstone] Updates from master branch (#1419)
AlicanCopur May 10, 2020
701f543
Merge pull request #1480 from NukkitX/master
SupremeMortal Jun 5, 2020
5b70933
Merge branch 'master' into redstone
Sleepybear Jul 14, 2020
b5b5af0
Merge branch 'master' into redstone
Sleepybear Sep 26, 2020
15da21f
merge master into redstone - fix build
Sleepybear Sep 26, 2020
9e6612d
Redstone 1.16.210 Support (#1817)
FlamingKnight Mar 28, 2021
cc74955
Redstone update for 1.16.221 (#1837)
FlamingKnight May 11, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,4 @@ creativeitems.json
recipes.json
data/
data/*
/src/main/resources/rebel.xml
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/Nukkit.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class Nukkit {

public final static Properties GIT_INFO = getGitInfo();
public final static String VERSION = getVersion();
public final static String API_VERSION = "1.0.9";
public final static String API_VERSION = "1.0.10";
public final static String CODENAME = "";
@Deprecated
public final static String MINECRAFT_VERSION = ProtocolInfo.MINECRAFT_VERSION;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -3195,7 +3195,7 @@ public void onCompletion(Server server) {
} else if (target instanceof Player) {
if ((((Player) target).getGamemode() & 0x01) > 0) {
break;
} else if (!this.server.getPropertyBoolean("pvp")) {
} else if (!this.server.getPropertyBoolean("pvp") || this.server.getDifficulty() == 0) {
break;
}
}
Expand Down
21 changes: 20 additions & 1 deletion src/main/java/cn/nukkit/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import cn.nukkit.blockentity.*;
import cn.nukkit.command.*;
import cn.nukkit.console.NukkitConsole;
import cn.nukkit.dispenser.DispenseBehaviorRegister;
import cn.nukkit.entity.Attribute;
import cn.nukkit.entity.Entity;
import cn.nukkit.entity.EntityHuman;
Expand Down Expand Up @@ -156,6 +157,8 @@ public class Server {

private boolean autoSave = true;

private boolean redstoneEnabled = true;

private RCON rcon;

private EntityMetadataStore entityMetadata;
Expand Down Expand Up @@ -387,6 +390,7 @@ public Level remove(Object key) {
this.autoTickRateLimit = this.getConfig("level-settings.auto-tick-rate-limit", 20);
this.alwaysTickPlayers = this.getConfig("level-settings.always-tick-players", false);
this.baseTickRate = this.getConfig("level-settings.base-tick-rate", 1);
this.redstoneEnabled = this.getConfig("level-settings.tick-redstone", true);

this.scheduler = new ServerScheduler();

Expand Down Expand Up @@ -453,6 +457,7 @@ public Level remove(Object key) {
Effect.init();
Potion.init();
Attribute.init();
DispenseBehaviorRegister.init();
GlobalBlockPalette.getOrCreateRuntimeId(0, 0); //Force it to load

// Convert legacy data before plugins get the chance to mess with it.
Expand Down Expand Up @@ -742,8 +747,11 @@ public boolean dispatchCommand(CommandSender sender, String commandLine) throws
if (!this.isPrimaryThread()) {
getLogger().warning("Command Dispatched Async: " + commandLine);
getLogger().warning("Please notify author of plugin causing this execution to fix this bug!", new Throwable());
// TODO: We should sync the command to the main thread too!

this.scheduler.scheduleTask(null, () -> dispatchCommand(sender, commandLine));
return true;
}

if (sender == null) {
throw new ServerException("CommandSender is not valid");
}
Expand Down Expand Up @@ -2023,6 +2031,14 @@ public boolean isLanguageForced() {
return forceLanguage;
}

public boolean isRedstoneEnabled() {
return redstoneEnabled;
}

public void setRedstoneEnabled(boolean redstoneEnabled) {
this.redstoneEnabled = redstoneEnabled;
}

public Network getNetwork() {
return network;
}
Expand Down Expand Up @@ -2333,6 +2349,9 @@ private void registerBlockEntities() {
BlockEntity.registerBlockEntity(BlockEntity.SHULKER_BOX, BlockEntityShulkerBox.class);
BlockEntity.registerBlockEntity(BlockEntity.BANNER, BlockEntityBanner.class);
BlockEntity.registerBlockEntity(BlockEntity.MUSIC, BlockEntityMusic.class);
BlockEntity.registerBlockEntity(BlockEntity.DISPENSER, BlockEntityDispenser.class);
BlockEntity.registerBlockEntity(BlockEntity.DROPPER, BlockEntityDropper.class);
BlockEntity.registerBlockEntity(BlockEntity.MOVING_BLOCK, BlockEntityMovingBlock.class);
}

public boolean isNetherAllowed() {
Expand Down
21 changes: 18 additions & 3 deletions src/main/java/cn/nukkit/block/Block.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public static void init() {
list[DRAGON_EGG] = BlockDragonEgg.class; //122
list[REDSTONE_LAMP] = BlockRedstoneLamp.class; //123
list[LIT_REDSTONE_LAMP] = BlockRedstoneLampLit.class; //124
//TODO: list[DROPPER] = BlockDropper.class; //125
list[DROPPER] = BlockDropper.class; //125
list[ACTIVATOR_RAIL] = BlockRailActivator.class; //126
list[COCOA] = BlockCocoa.class; //127
list[SANDSTONE_STAIRS] = BlockStairsSandstone.class; //128
Expand Down Expand Up @@ -296,8 +296,7 @@ public static void init() {
list[GLOWING_OBSIDIAN] = BlockObsidianGlowing.class; //246
//list[NETHER_REACTOR] = BlockNetherReactor.class; //247 Should not be removed

//TODO: list[PISTON_EXTENSION] = BlockPistonExtension.class; //250

list[MOVING_BLOCK] = BlockMoving.class; //250
list[OBSERVER] = BlockObserver.class; //251

for (int id = 0; id < 256; id++) {
Expand Down Expand Up @@ -488,6 +487,18 @@ public boolean canBePushed() {
return true;
}

public boolean canBePulled() {
return true;
}

public boolean breaksWhenMoved() {
return false;
}

public boolean sticksToPiston() {
return true;
}

public boolean hasComparatorInputOverride() {
return false;
}
Expand Down Expand Up @@ -691,6 +702,10 @@ public Block getSide(BlockFace face) {
}

public Block getSide(BlockFace face, int step) {
if (step == 0) {
return this;
}

if (this.isValid()) {
if (step == 1) {
return this.getLevel().getBlock((int) x + face.getXOffset(), (int) y + face.getYOffset(), (int) z + face.getZOffset());
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/cn/nukkit/block/BlockBanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,9 @@ public Item toItem() {
public BlockFace getBlockFace() {
return BlockFace.fromHorizontalIndex(this.getDamage() & 0x7);
}

@Override
public boolean breaksWhenMoved() {
return true;
}
}
5 changes: 5 additions & 0 deletions src/main/java/cn/nukkit/block/BlockBeacon.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,9 @@ public boolean place(Item item, Block block, Block target, BlockFace face, doubl
public boolean canBePushed() {
return false;
}

@Override
public boolean canBePulled() {
return false;
}
}
10 changes: 10 additions & 0 deletions src/main/java/cn/nukkit/block/BlockBed.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,14 @@ public DyeColor getDyeColor() {
public BlockFace getBlockFace() {
return BlockFace.fromHorizontalIndex(this.getDamage() & 0x7);
}

@Override
public boolean breaksWhenMoved() {
return true;
}

@Override
public boolean sticksToPiston() {
return false;
}
}
5 changes: 5 additions & 0 deletions src/main/java/cn/nukkit/block/BlockBedrock.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ public boolean canBePushed() {
return false;
}

@Override
public boolean canBePulled() {
return false;
}

@Override
public boolean canHarvestWithHand() {
return false;
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/cn/nukkit/block/BlockBedrockInvisible.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ public boolean canBePushed() {
return false;
}

@Override
public boolean canBePulled() {
return false;
}

@Override
public Item toItem() {
return new ItemBlock(new BlockAir());
Expand Down
29 changes: 18 additions & 11 deletions src/main/java/cn/nukkit/block/BlockButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,20 @@ public boolean onActivate(Item item, Player player) {
return false;
}

this.level.getServer().getPluginManager().callEvent(new BlockRedstoneEvent(this, 0, 15));
this.level.scheduleUpdate(this, 30);

if (this.level.getServer().isRedstoneEnabled()) {
this.level.getServer().getPluginManager().callEvent(new BlockRedstoneEvent(this, 0, 15));

Vector3 pos = getLocation();

level.updateAroundRedstone(pos, null);
level.updateAroundRedstone(pos.getSide(getFacing().getOpposite()), null);
}

this.setDamage(this.getDamage() ^ 0x08);
this.level.setBlock(this, this, true, false);
this.level.addSound(this.add(0.5, 0.5, 0.5), Sound.RANDOM_CLICK);
this.level.scheduleUpdate(this, 30);
Vector3 pos = getLocation();

level.updateAroundRedstone(pos, null);
level.updateAroundRedstone(pos.getSide(getFacing().getOpposite()), null);
return true;
}

Expand All @@ -75,15 +80,17 @@ public int onUpdate(int type) {
}
} else if (type == Level.BLOCK_UPDATE_SCHEDULED) {
if (this.isActivated()) {
this.level.getServer().getPluginManager().callEvent(new BlockRedstoneEvent(this, 15, 0));

this.setDamage(this.getDamage() ^ 0x08);
this.level.setBlock(this, this, true, false);
this.level.addSound(this.add(0.5, 0.5, 0.5), Sound.RANDOM_CLICK);

Vector3 pos = getLocation();
level.updateAroundRedstone(pos, null);
level.updateAroundRedstone(pos.getSide(getFacing().getOpposite()), null);
if (!this.level.getServer().isRedstoneEnabled()) {
this.level.getServer().getPluginManager().callEvent(new BlockRedstoneEvent(this, 15, 0));

Vector3 pos = getLocation();
level.updateAroundRedstone(pos, null);
level.updateAroundRedstone(pos.getSide(getFacing().getOpposite()), null);
}
}

return Level.BLOCK_UPDATE_SCHEDULED;
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/cn/nukkit/block/BlockCactus.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,21 @@ public String getName() {
public BlockColor getColor() {
return BlockColor.FOLIAGE_BLOCK_COLOR;
}

@Override
public Item[] getDrops(Item item) {
return new Item[]{
Item.get(Item.CACTUS, 0, 1)
Item.get(Item.CACTUS, 0, 1)
};
}

@Override
public boolean breaksWhenMoved() {
return true;
}

@Override
public boolean sticksToPiston() {
return false;
}
}
10 changes: 10 additions & 0 deletions src/main/java/cn/nukkit/block/BlockCake.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,14 @@ public int getComparatorInputOverride() {
public boolean hasComparatorInputOverride() {
return true;
}

@Override
public boolean breaksWhenMoved() {
return true;
}

@Override
public boolean sticksToPiston() {
return false;
}
}
10 changes: 10 additions & 0 deletions src/main/java/cn/nukkit/block/BlockChorusFlower.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,14 @@ public int getToolType() {
public Item[] getDrops(Item item) {
return new Item[0];
}

@Override
public boolean breaksWhenMoved() {
return true;
}

@Override
public boolean sticksToPiston() {
return false;
}
}
10 changes: 10 additions & 0 deletions src/main/java/cn/nukkit/block/BlockChorusPlant.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,14 @@ public int getToolType() {
public Item[] getDrops(Item item) {
return new Item[0];
}

@Override
public boolean breaksWhenMoved() {
return true;
}

@Override
public boolean sticksToPiston() {
return false;
}
}
10 changes: 10 additions & 0 deletions src/main/java/cn/nukkit/block/BlockCocoa.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,4 +244,14 @@ public Item[] getDrops(Item item) {
public BlockFace getBlockFace() {
return BlockFace.fromHorizontalIndex(this.getDamage() & 0x07);
}

@Override
public boolean breaksWhenMoved() {
return true;
}

@Override
public boolean sticksToPiston() {
return false;
}
}
Loading