@@ -104,9 +104,9 @@ public BlockState updateShape(
104104 RandomSource random ) {
105105 BlockState stateNew = super .updateShape (state , level , ticks , pos , directionToNeighbour , neighbourPos , neighbourState , random );
106106 if (!(level instanceof WorldGenRegion ) && stateNew .getBlock () instanceof SRMSnowLayerBlock ) {
107- BlockState contained = srm$getRaw (stateNew , level , pos );
108- BlockState containedNew = contained .updateShape (level , ticks , pos , directionToNeighbour , neighbourPos , neighbourState , random );
109- if (contained != containedNew ) {
107+ BlockState raw = srm$getRaw (stateNew , level , pos );
108+ BlockState containedNew = raw .updateShape (level , ticks , pos , directionToNeighbour , neighbourPos , neighbourState , random );
109+ if (raw != containedNew ) {
110110 if (containedNew .isAir ()) {
111111// level.destroyBlock(pos, true);
112112 return srm$getSnowState (state , level , pos );
@@ -141,7 +141,8 @@ protected void entityInside(
141141 if (raw .is (CoreModule .ENTITY_INSIDE )) {
142142 try {
143143 ((BlockBehaviourAccess ) raw .getBlock ()).callEntityInside (raw , level , pos , entity , effectApplier , isPrecise );
144- } catch (Throwable _) {
144+ } catch (Throwable e ) {
145+ Hooks .logError (e , "Error in entityInside of block %s" , raw );
145146 }
146147 }
147148 }
@@ -152,48 +153,53 @@ public void animateTick(BlockState state, Level level, BlockPos pos, RandomSourc
152153 if (raw .is (CoreModule .ANIMATE_TICK )) {
153154 try {
154155 raw .getBlock ().animateTick (raw , level , pos , random );
155- } catch (Throwable _) {
156+ } catch (Throwable e ) {
157+ Hooks .logError (e , "Error in animateTick of block %s" , raw );
156158 }
157159 }
158160 }
159161
160162 @ Override
161163 public void randomTick (BlockState state , ServerLevel level , BlockPos pos , RandomSource random ) {
162- BlockState stateIn = srm$getRaw (state , level , pos );
164+ BlockState raw = srm$getRaw (state , level , pos );
163165 try {
164166 super .randomTick (state , level , pos , random );
165167 } catch (Throwable e ) {
168+ Hooks .logError (e , "Error in randomTick stage 1 of block %s" , raw );
166169 return ;
167170 }
168- if (stateIn .getBlock () instanceof TallGrassBlock || stateIn .getBlock () instanceof DoublePlantBlock ) {
171+ if (raw .getBlock () instanceof TallGrassBlock || raw .getBlock () instanceof DoublePlantBlock ) {
169172 return ;
170173 }
171174 BlockState stateNow = level .getBlockState (pos );
172175 if (!stateNow .is (this )) {
173176 return ;
174177 }
175178 try {
176- stateIn .randomTick (level , pos , random );
179+ raw .randomTick (level , pos , random );
177180 BlockState stateNow2 = level .getBlockState (pos );
178181 if (!stateNow2 .is (this )) {
179- Hooks .convert (level , pos , stateNow2 , stateNow .getValue (LAYERS ), Block .UPDATE_CLIENTS | Block . UPDATE_KNOWN_SHAPE , true );
182+ Hooks .convert (level , pos , stateNow2 , stateNow .getValue (LAYERS ), Block .UPDATE_ALL , true );
180183 }
181- } catch (Throwable ignored ) {
184+ } catch (Throwable e ) {
185+ Hooks .logError (e , "Error in randomTick stage 2 of block %s" , raw );
182186 }
183187 }
184188
185189 @ Override
186190 protected InteractionResult useWithoutItem (BlockState state , Level level , BlockPos pos , Player player , BlockHitResult hitResult ) {
191+ BlockState raw = srm$getRaw (state , level , pos );
187192 try {
188- InteractionResult result = srm$getRaw ( state , level , pos ) .useWithoutItem (level , player , hitResult );
193+ InteractionResult result = raw .useWithoutItem (level , player , hitResult );
189194 if (result .consumesAction ()) {
190195 BlockState stateNow = level .getBlockState (pos );
191196 if (!stateNow .is (this )) {
192197 Hooks .convert (level , pos , stateNow , state .getValue (LAYERS ), Block .UPDATE_CLIENTS | Block .UPDATE_KNOWN_SHAPE , true );
193198 }
194199 return result ;
195200 }
196- } catch (Throwable ignored ) {
201+ } catch (Throwable e ) {
202+ Hooks .logError (e , "Error in useWithoutItem of block %s" , raw );
197203 }
198204 return super .useWithoutItem (state , level , pos , player , hitResult );
199205 }
@@ -207,16 +213,18 @@ protected InteractionResult useItemOn(
207213 Player player ,
208214 InteractionHand hand ,
209215 BlockHitResult hitResult ) {
216+ BlockState raw = srm$getRaw (state , level , pos );
210217 try {
211- InteractionResult result = srm$getRaw ( state , level , pos ) .useItemOn (itemStack , level , player , hand , hitResult );
218+ InteractionResult result = raw .useItemOn (itemStack , level , player , hand , hitResult );
212219 if (result .consumesAction ()) {
213220 BlockState stateNow = level .getBlockState (pos );
214221 if (!stateNow .is (this )) {
215222 Hooks .convert (level , pos , stateNow , state .getValue (LAYERS ), Block .UPDATE_CLIENTS | Block .UPDATE_KNOWN_SHAPE , true );
216223 }
217224 return result ;
218225 }
219- } catch (Throwable ignored ) {
226+ } catch (Throwable e ) {
227+ Hooks .logError (e , "Error in useItemOn of block %s" , raw );
220228 }
221229 return super .useItemOn (itemStack , state , level , pos , player , hand , hitResult );
222230 }
@@ -226,38 +234,39 @@ public void attack(BlockState state, Level level, BlockPos pos, Player player) {
226234 if (level .isClientSide ()) {
227235 return ;
228236 }
237+ BlockState raw = srm$getRaw (state , level , pos );
229238 try {
230- BlockState contained = srm$getRaw (state , level , pos );
231- if (!contained .isAir () && contained .getDestroySpeed (level , pos ) == 0 ) {
232- level .levelEvent (2001 , pos , Block .getId (contained ));
233- Block .dropResources (contained , level , pos , null , player , ItemStack .EMPTY );
239+ if (!raw .isAir () && raw .getDestroySpeed (level , pos ) == 0 ) {
240+ level .levelEvent (2001 , pos , Block .getId (raw ));
241+ Block .dropResources (raw , level , pos , null , player , ItemStack .EMPTY );
234242 int layers = state .getValue (LAYERS );
235243 level .setBlockAndUpdate (pos , Blocks .SNOW .defaultBlockState ().setValue (LAYERS , layers ));
236244 }
237- } catch (Throwable ignored ) {
245+ } catch (Throwable e ) {
246+ Hooks .logError (e , "Error in attack of block %s" , raw );
238247 }
239248 }
240249
241250 @ Override
242251 public boolean isValidBonemealTarget (LevelReader level , BlockPos pos , BlockState state ) {
243- BlockState contained = srm$getRaw (state , level , pos );
244- Block block = contained .getBlock ();
245- return block instanceof BonemealableBlock && ((BonemealableBlock ) block ).isValidBonemealTarget (level , pos , contained );
252+ BlockState raw = srm$getRaw (state , level , pos );
253+ Block block = raw .getBlock ();
254+ return block instanceof BonemealableBlock && ((BonemealableBlock ) block ).isValidBonemealTarget (level , pos , raw );
246255 }
247256
248257 @ Override
249258 public boolean isBonemealSuccess (Level level , RandomSource random , BlockPos pos , BlockState state ) {
250- BlockState contained = srm$getRaw (state , level , pos );
251- Block block = contained .getBlock ();
252- return block instanceof BonemealableBlock && ((BonemealableBlock ) block ).isBonemealSuccess (level , random , pos , contained );
259+ BlockState raw = srm$getRaw (state , level , pos );
260+ Block block = raw .getBlock ();
261+ return block instanceof BonemealableBlock && ((BonemealableBlock ) block ).isBonemealSuccess (level , random , pos , raw );
253262 }
254263
255264 @ Override
256265 public void performBonemeal (ServerLevel level , RandomSource random , BlockPos pos , BlockState state ) {
257- BlockState contained = srm$getRaw (state , level , pos );
258- Block block = contained .getBlock ();
266+ BlockState raw = srm$getRaw (state , level , pos );
267+ Block block = raw .getBlock ();
259268 if (block instanceof BonemealableBlock ) {
260- ((BonemealableBlock ) block ).performBonemeal (level , random , pos , contained );
269+ ((BonemealableBlock ) block ).performBonemeal (level , random , pos , raw );
261270 BlockState stateNow = level .getBlockState (pos );
262271 Hooks .convert (level , pos , stateNow , state .getValue (LAYERS ), Block .UPDATE_ALL , true );
263272 }
0 commit comments