1
0
Commit Graph

89 Commits

Author SHA1 Message Date
Tiger Wang
9b97d63f8f
Chest, weather, crash, and miscellaneous fixes (#5215)
* Alpha-sort cChestEntity

* Chests: use SendUpdateBlockEntity

* Pathfinder: fix out of range Y

* 1.13: correct weather packet ID

* Chests: fix neighbour scanner

+ Add OnAddToWorld and overload to scan neighbours there, instead of in the constructor/OnUse. This fixes hoppers accessing newly loaded double chests and seeing a null m_Neighbour, thus thinking its a single chest.
* Fix typo in cross coords computation.
* Simplify hopper logic.

* Block entities: ASSERT that type is correct

If you match the block type first before calling DoWithBlockEntity, the corresponding block entity must either be empty or correspond to the block type.

* Chunk: fix some forgotten PendingSendBE cleanup

+ Add cleanup in SetAllData, WriteBlockArea
- Remove RemoveBlockEntity (used once), HasBlockEntity (not used)

* Replace MakeIndex with MakeIndexNoCheck

* Remove extraneous MarkDirty in hopper & chests
2021-04-30 13:23:46 +00:00
Tiger Wang
7080c4d3e2 Hoppers: use 'locked' bit in meta 2021-04-12 22:35:07 +01:00
Tiger Wang
4cd49d7eca Fix sending incorrect date values on world change
Yak shave: make more things use cTickTime. Fix a couple of incorrect modulo-on-millisecond-value by making them use WorldTickAge.
2021-04-12 22:35:07 +01:00
Tiger Wang
5d11816015 Move some redstone implementations into the source file 2021-03-28 15:36:10 +01:00
Tiger Wang
748b121703
Unify DoWithBlockEntity (#5168)
+ DoWith calls now broadcast the block entity and mark the chunk dirty
+ Add block entity change queue to synchronise BE updates with block updates
* Fixed a few incorrect assertions about BE type
- Remove manual overloads
2021-03-28 14:40:57 +01:00
Tiger Wang
868cd94ee9
Prepare ChunkData for BlockState storage (#5105)
* Rename ChunkData Creatable test

* Add missing Y-check in RedstoneWireHandler

* Remove ChunkDef.h dependency in Scoreboard

* Prepare ChunkData for BlockState storage

+ Split chunk block, meta, block & sky light storage
+ Load the height map from disk
- Reduce duplicated code in ChunkData
- Remove saving MCSBiomes, there aren't any
- Remove the allocation pool, ref #4315, #3864

* fixed build

* fixed test

* fixed the debug compile

Co-authored-by: 12xx12 <44411062+12xx12@users.noreply.github.com>
2021-03-05 14:03:55 +01:00
Tiger Wang
6aa1d13508 Clang 7? 2021-02-11 01:24:50 +00:00
Tiger Wang
19302eeb87 Redstone: inline -> static 2021-01-22 22:04:47 +00:00
Tiger Wang
813176fbd1
cChunk: don't inherit from cChunkDef (#5106) 2021-01-18 16:09:10 +00:00
Tiger Wang
14ada52f3a Daylight Sensor: remove redundant delay
Daylight Sensors are already always ticked.
2020-12-26 16:58:53 +00:00
Tiger Wang
9518a27357
Prepare for 1.15+ (#4856)
+ Add type-safe container for states
* Split registry Blocks into BlockTypes, BlockStates so the block types enumeration can be #included without too much penalty
* Ensure Registry uses type-safe container
2020-12-21 13:54:04 +00:00
Aiden Neill
a7e9f88ff3
New pull request for daylight sensor (#5066)
* Fixes #4918

Co-authored-by: Tiger Wang <ziwei.tiger@outlook.com>
2020-12-19 01:42:34 +00:00
Tiger Wang
090d8305e4 Warnings improvements
* Turn off global-constructors warning. These are needed to implement cRoot signal handler functionality
* Add Clang flags based on version lookup instead of a compile test. The CMake config process is single threaded and slow enough already
* Reduced GetStackValue verbosity
+ Clarify EnchantmentLevel, StayCount, AlwaysTicked, ViewDistance signedness
+ Give SettingsRepositoryInterface a move constructor to simplify main.cpp code
- Remove do {} while (false) construction in redstone handler
2020-12-18 21:03:40 +00:00
peterbell10
a9031b6bae
Fix cmake not adding Werror on clang, and _lots_ of warnings (#4963)
* Fix cmake not adding Werror on clang, and _lots_ of warnings

* WIP: Build fixes

* Cannot make intermediate blockhandler instance

* Tiger's changes

* Fix BitIndex check

* Handle invalid NextState values in cMultiVersionProtocol

Co-authored-by: Tiger Wang <ziwei.tiger@outlook.com>
2020-10-05 10:27:14 +00:00
Tiger Wang
429117c1f6 Doors: check power & toggle correctly
* Fixed upper half ignoring its updates
* Fixes #4945
* Fixed doors playing sound effects when they didn't actually toggle
2020-09-28 23:40:19 +01:00
Tiger Wang
6183b28f93
Implement redstone quasi-connectivity (#4889) 2020-09-21 20:39:58 +01:00
Tiger Wang
93adbdce9a
Use tracing for explosions (#4845)
* TNT: Implement tracing algorithm

+ Add intensity tracing
* Fix iterating over all players to SendExplosion, even those not in range

* Implemented TNT entity interaction

* Fixed misaligned destruction tracing

* Finalise TNT algorithm

- Remove BlockArea and just use chunks

Using SetBlock makes it so that we can update everything properly, and does appear to be faster.

* BlockInfo learns about explosion attentuation

* Rename Explodinator parameters

* TNT: pull block destruction into common function

Co-authored-by: Alexander Harkness <me@bearbin.net>
2020-09-12 18:57:44 +00:00
Tiger Wang
5d736b653f Minor style fixes 2020-08-28 21:42:37 +01:00
Peter Bell
fa917259a5 Fix doors and trapdoors closing on server restart 2020-08-25 21:38:49 +01:00
Tiger Wang
d8c8d0124d Replace PowerData struct with PowerLevel
* We no longer need to track the powering block with the removal of SolidBlockHandler. PowerLevel is now just an unsigned char
2020-08-21 00:50:09 +01:00
Tiger Wang
3143d6ce67 Remove std::make_unique from redstone handler creation 2020-08-21 00:50:09 +01:00
Tiger Wang
40eba5244d Remove the redstone solid block handler
- Remove cSolidBlockHandler
* Functionality now integrated into simulator dispatcher
* Fix door double open/close issues, arisen due to the top/bottom halves getting different power
+ Small migration to block states for redstone wire
2020-08-08 18:22:16 +01:00
Tiger Wang
adb86a75da Do not GetBlock individually in simulators
* Have the simulator manager get the block and pass it on
+ Add new overload for WakeUp, called when the manager wakes face positions
2020-08-04 18:15:18 +01:00
Tiger Wang
225c2fa9f6 Always use relative coordinates in AddBlock
+ Pass block, use relatives
* Fixes everything immediately converting abs back to rel and getting block, when these data were already available
2020-08-02 15:52:06 +01:00
Tiger Wang
99856df686 Add WakeUp/AddBlock distinction
* WakeUp is for singular changes (block breaking for example). The simulator should check blocks around the position and discover other affected blocks as it sees fit
* AddBlock is for when you know a whole area is to be updated; chunk loading, or area wakeups for example
+ Prepares for correct handling of destroyed blocks after removal of SolidBlockHandler in the redstone simulator
2020-08-02 15:52:06 +01:00
Tiger Wang
6c47f46c31 Ensure updating relatives calls the correct base case
* Fixed recursive base unintentionally scheduling the origin position for an update because it called the wrong function
2020-08-02 15:52:06 +01:00
Mattes D
46398f4671 Replaced cpp14::make_unique<> with std::make_unique<>. 2020-08-01 20:04:31 +01:00
Tiger Wang
1673c84978 Remove redundant ErasePowerData call
* Also fix a return that should've been continue
2020-07-26 16:08:20 +01:00
Tiger Wang
7d93742498 Clang Tidy fix 2020-07-26 16:06:57 +01:00
Tiger Wang
2e18e4f51c Comparators: use <= in comparison mode 2020-07-26 14:16:46 +01:00
Tiger Wang
4e5ab02a58 Use SimulateChunk in redstone simulator
+ Improved performance, reduces bottleneck in chunkmap lookup
* Stop allocating and throwing away lots of small vectors in Update/GetValidSourcePositions return values
- Remove unused GetPowerLevel virtual
2020-07-26 14:16:46 +01:00
Tiger Wang
bc01cd5e75 Redstone: check validity of GetBlock 2020-07-24 09:11:40 +01:00
Tiger Wang
3f712ca9cf Precompile unordered_map/set
+ Add inclusions to Globals.h
* Sort Globals.h
- Remove sys/stat.h from Globals.h
2020-07-19 19:58:53 +01:00
Tiger Wang
9e8598fb1c
Upgrade to C++17 [CMake] (#4717)
* Make our CMake slightly less insane
2020-05-16 20:59:10 +01:00
Tiger Wang
a9e06d33c5 Add some comments about terracing 2020-05-08 10:52:35 +01:00
Tiger Wang
6ac11925f1 Update RedstoneWireHandler style 2020-05-08 10:52:35 +01:00
peterbell10
c4ca11b372
Fix SetBlockMeta call in observer handler (#4728) 2020-05-08 09:46:03 +01:00
DrButcher
258318ab98
Buttons can now be triggered by arrows. (#4670)
* Buttons can now be triggered by arrows.
2020-05-03 21:05:32 +01:00
mBornand
5b92e6654f Update src/Simulator/IncrementalRedstoneSimulator/RedstoneWireHandler.h
Co-authored-by: peterbell10 <peterbell10@live.co.uk>
2020-05-03 11:51:11 +01:00
mBornand
1c579f58aa Update src/Simulator/IncrementalRedstoneSimulator/RedstoneWireHandler.h
Co-authored-by: peterbell10 <peterbell10@live.co.uk>
2020-05-03 11:51:11 +01:00
Marc_Bornand
83193f132c Made some style update and add comments 2020-05-03 11:51:11 +01:00
Marc_Bornand
055c9ef90e Fix the connexion to the side of the repeater 2020-05-03 11:51:11 +01:00
Mattes D
487f9a2aa9
Vector3 in Handlers (#4680)
Refactored all cBlockHandler and cItemHandler descendants to use Vector3.
2020-04-21 22:19:22 +02:00
Tiger Wang
c1ea5f982d Re-implement repeater locking 2020-04-18 16:51:29 +01:00
DrButcher
3591be50b2
Fixing washing away of redstone mechanisms (#4665) 2020-04-17 21:01:21 +01:00
Tiger Wang
ede56a5750
ಠ_ಠ (#4660)
+ Provisional handling for observers
2020-04-16 22:27:04 +01:00
Mattes D
9ee47e5999 Using Super. 2020-04-16 20:07:48 +00:00
DrButcher
35299b8509
Pressure plate sounds and delay (#4643)
+ Added sounds on depress and release
+ Added correct delay times
2020-04-13 23:23:43 +01:00
peterbell10
19ad96561c
Filter blocks to add to redstone sim's wake queue (#4621) 2020-04-05 19:20:52 +00:00
Bond-009
ea386eaab1
Lock hopper when powered by redstone (#4347)
* Lock hopper when powered by redstone

* Add to manual bindings

* Add hopper API documentation

Co-authored-by: Mat <mail@mathias.is>
2020-03-27 12:03:28 +00:00