Files
MinecraftForge/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch
T
4ed9117799 Forge 1.19
* Bump pack.mcmeta formats
* 1.19 biome modifiers
* Mark ClientPlayerNetworkEvent.LoggedOutEvent's getters as nullable
* Add docs and package-info to client extension interfaces package
* Move RenderBlockOverlayEvent hooks to ForgeHooksClient
* Add package-infos to client events package
* Rename SoundLoadEvent to SoundEngineLoadEvent

This reduces confusion from consumers which may think the
name SoundLoadEvent refers to an individual sound being loaded rather
than the sound engine.
* Document and change SoundLoadEvent to fire on mod bus

Previously, it fired on both the mod bus and the Forge bus, which is
confusing for consumers.
* Delete SoundSetupEvent

Looking at its original implementation shows that there isn't an
appropriate place in the new sound code to reinsert the event, and the
place of 'sound engine/manager initialization event' is taken already by SoundLoadEvent.
* Perform some cleanup on client events

 - Removed nullable annotations from ClientPlayerNetworkEvent
 - Renamed #getPartialTicks methods to #getPartialTick, to be consistent
  with vanilla's naming of the partial tick
 - Cleanup documentation to remove line breaks, use the
  spelling 'cancelled' over
  'canceled', and improve docs on existing and
   new methods.
* Remove EntityEvent.CanUpdate

Closes MinecraftForge/MinecraftForge#6394
* Switch to Jetbrains nullability annotations
* New PlayLevelSoundEvent; replaces old PlaySoundAtEntityEvent
* Remove ForgeWorldPresetScreens
* Remove IForgeRegistryEntry
* Remove use of List<Throwable> in FML's CompletableFutures
* Add docs to mod loading stages, stages, and phases
* Gradle 7.4.2
* Use SLF4J in FMLLoader and other subprojects
* Switch dynamic versions in subprojects to pinned ones
* Switch ForgeRoot and MDK to FG plugin markers
* Configure Forge javadoc task

The task now uses a custom stylesheet with MCForge elements, and
configured to combine the generation from the four FML subprojects
(fmlloader, fmlcore, javafmllanguage, mclanguage) and the Forge project
into the javadoc output.
* Update docs/md files, for 1.19 update and the move away from IRC to Discord.
* Make "Potentially dangerous alternative prefix" a debug warning, not info.

Co-authored-by: Curle <[email protected]>
Co-authored-by: sciwhiz12 <[email protected]>
Signed-off-by: SizableShrimp <[email protected]>
2022-06-07 15:31:26 -05:00

129 lines
7.1 KiB
Diff

--- a/net/minecraft/server/level/ServerPlayerGameMode.java
+++ b/net/minecraft/server/level/ServerPlayerGameMode.java
@@ -124,6 +_,10 @@
}
public void m_214168_(BlockPos p_215120_, ServerboundPlayerActionPacket.Action p_215121_, Direction p_215122_, int p_215123_, int p_215124_) {
+ net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickBlock event = net.minecraftforge.common.ForgeHooks.onLeftClickBlock(f_9245_, p_215120_, p_215122_);
+ if (event.isCanceled() || (!this.m_9295_() && event.getResult() == net.minecraftforge.eventbus.api.Event.Result.DENY)) {
+ return;
+ }
if (this.f_9245_.m_146892_().m_82557_(Vec3.m_82512_(p_215120_)) > ServerGamePacketListenerImpl.f_215198_) {
this.m_215125_(p_215120_, false, p_215124_, "too far");
} else if (p_215120_.m_123342_() >= p_215123_) {
@@ -152,6 +_,7 @@
float f = 1.0F;
BlockState blockstate = this.f_9244_.m_8055_(p_215120_);
if (!blockstate.m_60795_()) {
+ if (event.getUseBlock() != net.minecraftforge.eventbus.api.Event.Result.DENY)
blockstate.m_60686_(this.f_9244_, p_215120_, this.f_9245_);
f = blockstate.m_60625_(this.f_9245_, this.f_9245_.f_19853_, p_215120_);
}
@@ -221,7 +_,8 @@
public boolean m_9280_(BlockPos p_9281_) {
BlockState blockstate = this.f_9244_.m_8055_(p_9281_);
- if (!this.f_9245_.m_21205_().m_41720_().m_6777_(blockstate, this.f_9244_, p_9281_, this.f_9245_)) {
+ int exp = net.minecraftforge.common.ForgeHooks.onBlockBreakEvent(f_9244_, f_9247_, f_9245_, p_9281_);
+ if (exp == -1) {
return false;
} else {
BlockEntity blockentity = this.f_9244_.m_7702_(p_9281_);
@@ -229,30 +_,42 @@
if (block instanceof GameMasterBlock && !this.f_9245_.m_36337_()) {
this.f_9244_.m_7260_(p_9281_, blockstate, blockstate, 3);
return false;
+ } else if (f_9245_.m_21205_().onBlockStartBreak(p_9281_, f_9245_)) {
+ return false;
} else if (this.f_9245_.m_36187_(this.f_9244_, p_9281_, this.f_9247_)) {
return false;
} else {
- block.m_5707_(this.f_9244_, p_9281_, blockstate, this.f_9245_);
- boolean flag = this.f_9244_.m_7471_(p_9281_, false);
- if (flag) {
- block.m_6786_(this.f_9244_, p_9281_, blockstate);
- }
-
if (this.m_9295_()) {
+ removeBlock(p_9281_, false);
return true;
} else {
ItemStack itemstack = this.f_9245_.m_21205_();
ItemStack itemstack1 = itemstack.m_41777_();
- boolean flag1 = this.f_9245_.m_36298_(blockstate);
+ boolean flag1 = blockstate.canHarvestBlock(this.f_9244_, p_9281_, this.f_9245_); // previously player.hasCorrectToolForDrops(blockstate)
itemstack.m_41686_(this.f_9244_, blockstate, p_9281_, this.f_9245_);
+ if (itemstack.m_41619_() && !itemstack1.m_41619_())
+ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this.f_9245_, itemstack1, InteractionHand.MAIN_HAND);
+ boolean flag = removeBlock(p_9281_, flag1);
+
if (flag && flag1) {
block.m_6240_(this.f_9244_, this.f_9245_, p_9281_, blockstate, blockentity, itemstack1);
}
+ if (flag && exp > 0)
+ blockstate.m_60734_().m_49805_(f_9244_, p_9281_, exp);
+
return true;
}
}
}
+ }
+
+ private boolean removeBlock(BlockPos p_180235_1_, boolean canHarvest) {
+ BlockState state = this.f_9244_.m_8055_(p_180235_1_);
+ boolean removed = state.onDestroyedByPlayer(this.f_9244_, p_180235_1_, this.f_9245_, canHarvest, this.f_9244_.m_6425_(p_180235_1_));
+ if (removed)
+ state.m_60734_().m_6786_(this.f_9244_, p_180235_1_, state);
+ return removed;
}
public InteractionResult m_6261_(ServerPlayer p_9262_, Level p_9263_, ItemStack p_9264_, InteractionHand p_9265_) {
@@ -261,6 +_,8 @@
} else if (p_9262_.m_36335_().m_41519_(p_9264_.m_41720_())) {
return InteractionResult.PASS;
} else {
+ InteractionResult cancelResult = net.minecraftforge.common.ForgeHooks.onItemRightClick(p_9262_, p_9265_);
+ if (cancelResult != null) return cancelResult;
int i = p_9264_.m_41613_();
int j = p_9264_.m_41773_();
InteractionResultHolder<ItemStack> interactionresultholder = p_9264_.m_41682_(p_9263_, p_9262_, p_9265_);
@@ -297,6 +_,8 @@
public InteractionResult m_7179_(ServerPlayer p_9266_, Level p_9267_, ItemStack p_9268_, InteractionHand p_9269_, BlockHitResult p_9270_) {
BlockPos blockpos = p_9270_.m_82425_();
BlockState blockstate = p_9267_.m_8055_(blockpos);
+ net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock event = net.minecraftforge.common.ForgeHooks.onRightClickBlock(p_9266_, p_9269_, blockpos, p_9270_);
+ if (event.isCanceled()) return event.getCancellationResult();
if (this.f_9247_ == GameType.SPECTATOR) {
MenuProvider menuprovider = blockstate.m_60750_(p_9267_, blockpos);
if (menuprovider != null) {
@@ -306,10 +_,15 @@
return InteractionResult.PASS;
}
} else {
+ UseOnContext useoncontext = new UseOnContext(p_9266_, p_9269_, p_9270_);
+ if (event.getUseItem() != net.minecraftforge.eventbus.api.Event.Result.DENY) {
+ InteractionResult result = p_9268_.onItemUseFirst(useoncontext);
+ if (result != InteractionResult.PASS) return result;
+ }
boolean flag = !p_9266_.m_21205_().m_41619_() || !p_9266_.m_21206_().m_41619_();
- boolean flag1 = p_9266_.m_36341_() && flag;
+ boolean flag1 = (p_9266_.m_36341_() && flag) && !(p_9266_.m_21205_().doesSneakBypassUse(p_9267_, blockpos, p_9266_) && p_9266_.m_21206_().doesSneakBypassUse(p_9267_, blockpos, p_9266_));
ItemStack itemstack = p_9268_.m_41777_();
- if (!flag1) {
+ if (event.getUseBlock() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || (event.getUseBlock() != net.minecraftforge.eventbus.api.Event.Result.DENY && !flag1)) {
InteractionResult interactionresult = blockstate.m_60664_(p_9267_, p_9266_, p_9269_, p_9270_);
if (interactionresult.m_19077_()) {
CriteriaTriggers.f_10562_.m_220040_(p_9266_, blockpos, itemstack);
@@ -317,8 +_,8 @@
}
}
- if (!p_9268_.m_41619_() && !p_9266_.m_36335_().m_41519_(p_9268_.m_41720_())) {
- UseOnContext useoncontext = new UseOnContext(p_9266_, p_9269_, p_9270_);
+ if (event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || (!p_9268_.m_41619_() && !p_9266_.m_36335_().m_41519_(p_9268_.m_41720_()))) {
+ if (event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.DENY) return InteractionResult.PASS;
InteractionResult interactionresult1;
if (this.m_9295_()) {
int i = p_9268_.m_41613_();