Skip to content

Commit

Permalink
fixed a server crash with neurotoxin
Browse files Browse the repository at this point in the history
  • Loading branch information
Fusion-Flux committed May 19, 2021
1 parent 6fa74ba commit aefb29d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
package com.fusionflux.thinkingwithportatos.blocks.blockentities;

import com.fusionflux.thinkingwithportatos.blocks.ThinkingWithPortatosBlocks;
import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;

public class NeurotoxinBlock extends BlockWithEntity {
protected static final VoxelShape SHAPE = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 16.0D, 16.0D);

private int timeinblock = 1;
private int timerdiff = 1;

public NeurotoxinBlock(Settings settings) {
super(settings);
}
Expand Down Expand Up @@ -46,5 +53,11 @@ public BlockRenderType getRenderType(BlockState state) {
return BlockRenderType.MODEL;
}

@Override
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
if (!world.isClient) {
entity.damage(DamageSource.DROWN, 1);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import com.fusionflux.thinkingwithportatos.blocks.ThinkingWithPortatosBlocks;
import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemStack;
import net.minecraft.state.StateManager;
Expand All @@ -21,6 +23,8 @@ public class NeurotoxinEmitterBlock extends BlockWithEntity {

protected static final VoxelShape SHAPE = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 16.0D, 16.0D);



public NeurotoxinEmitterBlock(Settings settings) {
super(settings);
}
Expand Down Expand Up @@ -80,4 +84,6 @@ public BlockState rotate(BlockState state, BlockRotation rotation) {
}




}
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ public abstract class EntityMixin implements EntityAttachments, VelocityTransfer
@Unique
private double maxFallSpeed = 0;
@Unique
private final double repulsionGelSoundLimiter = 0;
@Unique
private double storeVelocity1 = 0;
@Unique
private double storeVelocity2 = 0;
Expand Down Expand Up @@ -105,8 +103,6 @@ public void setMaxFallSpeed(double maxFallSpeed) {
@Shadow
public abstract boolean damage(DamageSource source, float amount);

@Shadow
public abstract float getEyeHeight(EntityPose pose);

@Shadow
public abstract EntityPose getPose();
Expand All @@ -117,6 +113,7 @@ public void setMaxFallSpeed(double maxFallSpeed) {
@Shadow
public abstract boolean isSneaking();


@Override
public List<CustomPortalEntity> getPortalList() {
return portalList;
Expand Down Expand Up @@ -159,13 +156,6 @@ public void tick(CallbackInfo ci) {
}

if (!world.isClient) {
if (world.getBlockState(new BlockPos(this.getX(), this.getY() + this.getEyeHeight(this.getPose()), this.getZ())) == ThinkingWithPortatosBlocks.NEUROTOXIN_BLOCK.getDefaultState()) {
if (Math.abs(timeinblock - this.age) > 20) {
this.damage(DamageSource.DROWN, 2);
}
} else {
timeinblock = this.age;
}

List<Entity> portalSound = this.world.getEntitiesByClass(CustomPortalEntity.class, this.getBoundingBox().expand(2), null);

Expand Down

0 comments on commit aefb29d

Please sign in to comment.