1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
--- a/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java
+++ b/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java
@@ -8,7 +8,7 @@
import net.minecraft.network.syncher.EntityDataSerializers;
import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.server.level.ServerLevel;
-import net.minecraft.world.InteractionHand;
+import net.minecraft.world.EnumHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.player.Player;
@@ -17,13 +17,14 @@
import net.minecraft.world.level.BaseCommandBlock;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks;
-import net.minecraft.world.level.block.state.BlockState;
+import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.phys.Vec3;
public class MinecartCommandBlock extends AbstractMinecart {
- static final EntityDataAccessor<String> DATA_ID_COMMAND_NAME = SynchedEntityData.defineId(MinecartCommandBlock.class, EntityDataSerializers.STRING);
+
+ public static final EntityDataAccessor<String> DATA_ID_COMMAND_NAME = SynchedEntityData.defineId(MinecartCommandBlock.class, EntityDataSerializers.STRING);
static final EntityDataAccessor<Component> DATA_ID_LAST_OUTPUT = SynchedEntityData.defineId(MinecartCommandBlock.class, EntityDataSerializers.COMPONENT);
- private final BaseCommandBlock commandBlock = new MinecartCommandBlock.MinecartCommandBase();
+ private final BaseCommandBlock commandBlock = new MinecartCommandBlock.a();
private static final int ACTIVATION_DELAY = 4;
private int lastActivated;
@@ -31,8 +32,8 @@
super(entityType, level);
}
- public MinecartCommandBlock(Level level, double x, double y, double z) {
- super(EntityType.COMMAND_BLOCK_MINECART, level, x, y, z);
+ public MinecartCommandBlock(Level level, double x, double d1, double y) {
+ super(EntityType.COMMAND_BLOCK_MINECART, level, x, d1, y);
}
@Override
@@ -43,16 +44,16 @@
@Override
protected void defineSynchedData() {
super.defineSynchedData();
- this.getEntityData().define(DATA_ID_COMMAND_NAME, "");
- this.getEntityData().define(DATA_ID_LAST_OUTPUT, CommonComponents.EMPTY);
+ this.getEntityData().define(MinecartCommandBlock.DATA_ID_COMMAND_NAME, "");
+ this.getEntityData().define(MinecartCommandBlock.DATA_ID_LAST_OUTPUT, CommonComponents.EMPTY);
}
@Override
protected void readAdditionalSaveData(CompoundTag compound) {
super.readAdditionalSaveData(compound);
this.commandBlock.load(compound);
- this.getEntityData().set(DATA_ID_COMMAND_NAME, this.getCommandBlock().getCommand());
- this.getEntityData().set(DATA_ID_LAST_OUTPUT, this.getCommandBlock().getLastOutput());
+ this.getEntityData().set(MinecartCommandBlock.DATA_ID_COMMAND_NAME, this.getCommandBlock().getCommand());
+ this.getEntityData().set(MinecartCommandBlock.DATA_ID_LAST_OUTPUT, this.getCommandBlock().getLastOutput());
}
@Override
@@ -62,12 +63,12 @@
}
@Override
- public AbstractMinecart.Type getMinecartType() {
- return AbstractMinecart.Type.COMMAND_BLOCK;
+ public AbstractMinecart.EnumMinecartType getMinecartType() {
+ return AbstractMinecart.EnumMinecartType.COMMAND_BLOCK;
}
@Override
- public BlockState getDefaultDisplayBlockState() {
+ public IBlockData getDefaultDisplayBlockState() {
return Blocks.COMMAND_BLOCK.defaultBlockState();
}
@@ -81,24 +82,27 @@
this.getCommandBlock().performCommand(this.level());
this.lastActivated = this.tickCount;
}
+
}
@Override
- public InteractionResult interact(Player player, InteractionHand hand) {
+ public InteractionResult interact(Player player, EnumHand hand) {
return this.commandBlock.usedBy(player);
}
@Override
public void onSyncedDataUpdated(EntityDataAccessor<?> key) {
super.onSyncedDataUpdated(key);
- if (DATA_ID_LAST_OUTPUT.equals(key)) {
+ if (MinecartCommandBlock.DATA_ID_LAST_OUTPUT.equals(key)) {
try {
- this.commandBlock.setLastOutput(this.getEntityData().get(DATA_ID_LAST_OUTPUT));
- } catch (Throwable var3) {
+ this.commandBlock.setLastOutput((Component) this.getEntityData().get(MinecartCommandBlock.DATA_ID_LAST_OUTPUT));
+ } catch (Throwable throwable) {
+ ;
}
- } else if (DATA_ID_COMMAND_NAME.equals(key)) {
- this.commandBlock.setCommand(this.getEntityData().get(DATA_ID_COMMAND_NAME));
+ } else if (MinecartCommandBlock.DATA_ID_COMMAND_NAME.equals(key)) {
+ this.commandBlock.setCommand((String) this.getEntityData().get(MinecartCommandBlock.DATA_ID_COMMAND_NAME));
}
+
}
@Override
@@ -106,10 +110,13 @@
return true;
}
- public class MinecartCommandBase extends BaseCommandBlock {
+ public class a extends BaseCommandBlock {
+
+ public a() {}
+
@Override
public ServerLevel getLevel() {
- return (ServerLevel)MinecartCommandBlock.this.level();
+ return (ServerLevel) MinecartCommandBlock.this.level();
}
@Override
@@ -129,22 +136,19 @@
@Override
public CommandSourceStack createCommandSourceStack() {
- return new CommandSourceStack(
- this,
- MinecartCommandBlock.this.position(),
- MinecartCommandBlock.this.getRotationVector(),
- this.getLevel(),
- 2,
- this.getName().getString(),
- MinecartCommandBlock.this.getDisplayName(),
- this.getLevel().getServer(),
- MinecartCommandBlock.this
- );
+ return new CommandSourceStack(this, MinecartCommandBlock.this.position(), MinecartCommandBlock.this.getRotationVector(), this.getLevel(), 2, this.getName().getString(), MinecartCommandBlock.this.getDisplayName(), this.getLevel().getServer(), MinecartCommandBlock.this);
}
@Override
public boolean isValid() {
return !MinecartCommandBlock.this.isRemoved();
}
+
+ // CraftBukkit start
+ @Override
+ public org.bukkit.command.CommandSender getBukkitSender(CommandSourceStack wrapper) {
+ return (org.bukkit.craftbukkit.entity.CraftMinecartCommand) MinecartCommandBlock.this.getBukkitEntity();
+ }
+ // CraftBukkit end
}
}
|